aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jake2/Globals.java3
-rw-r--r--src/jake2/client/CL.java6
-rw-r--r--src/jake2/client/CL_fx.java90
-rw-r--r--src/jake2/client/CL_newfx.java30
-rw-r--r--src/jake2/client/CL_parse.java16
-rw-r--r--src/jake2/client/CL_pred.java27
-rw-r--r--src/jake2/client/CL_tent.java8
-rw-r--r--src/jake2/client/CL_view.java14
-rw-r--r--src/jake2/client/Key.java15
-rw-r--r--src/jake2/client/M.java9
-rw-r--r--src/jake2/client/SCR.java12
-rw-r--r--src/jake2/client/SND_DMA.java881
-rw-r--r--src/jake2/client/SND_JAVA.java4
-rw-r--r--src/jake2/client/SND_MIX.java82
-rw-r--r--src/jake2/client/VID.java6
-rw-r--r--src/jake2/client/refimport_t.java8
-rw-r--r--src/jake2/client/sfx_t.java9
-rw-r--r--src/jake2/game/GameAIAdapters.java27
-rw-r--r--src/jake2/game/GameMiscAdapters.java4
-rw-r--r--src/jake2/game/PlayerClient.java4
-rw-r--r--src/jake2/game/client_persistant_t.java21
-rw-r--r--src/jake2/game/client_respawn_t.java4
-rw-r--r--src/jake2/game/cplane_t.java25
-rw-r--r--src/jake2/game/player_state_t.java4
-rw-r--r--src/jake2/game/trace_t.java28
-rw-r--r--src/jake2/qcommon/MSG.java16
-rw-r--r--src/jake2/qcommon/Qcommon.java7
-rw-r--r--src/jake2/qcommon/qfiles.java48
-rw-r--r--src/jake2/render/jogl/Image.java357
-rw-r--r--src/jake2/render/jogl/Impl.java21
-rw-r--r--src/jake2/render/jogl/Light.java242
-rw-r--r--src/jake2/render/jogl/Mesh.java6
-rw-r--r--src/jake2/render/jogl/Surf.java351
-rw-r--r--src/jake2/render/jogl/Warp.java5
-rw-r--r--src/jake2/render/msurface_t.java43
-rw-r--r--src/jake2/server/SV_GAME.java10
-rw-r--r--src/jake2/server/SV_INIT.java4
-rw-r--r--src/jake2/server/SV_SEND.java6
-rw-r--r--src/jake2/server/SV_USER.java13
-rw-r--r--src/jake2/server/SV_WORLD.java4
-rw-r--r--src/jake2/sys/Sys.java4
-rw-r--r--src/jake2/util/Math3D.java105
42 files changed, 1345 insertions, 1234 deletions
diff --git a/src/jake2/Globals.java b/src/jake2/Globals.java
index 27b6e4a..32771bf 100644
--- a/src/jake2/Globals.java
+++ b/src/jake2/Globals.java
@@ -2,7 +2,7 @@
* Globals.java
* Copyright (C) 2003
*
- * $Id: Globals.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+ * $Id: Globals.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -84,7 +84,6 @@ public class Globals extends Defines {
public static cvar_t cl_upspeed;
public static cvar_t cl_yawspeed;
public static cvar_t dedicated;
- public static cvar_t slomo;
public static cvar_t developer;
public static cvar_t fixedtime;
public static cvar_t freelook;
diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java
index 3522aa2..18d19be 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.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: CL.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -1540,8 +1540,8 @@ public final class CL extends CL_pred {
if (!cl.refresh_prepped && cls.state == ca_active) {
CL.PrepRefresh();
// TODO force GC after level loading
- //System.gc();
- //System.gc();
+ System.gc();
+ System.gc();
}
SCR.UpdateScreen();
diff --git a/src/jake2/client/CL_fx.java b/src/jake2/client/CL_fx.java
index 86642ee..2a77d21 100644
--- a/src/jake2/client/CL_fx.java
+++ b/src/jake2/client/CL_fx.java
@@ -2,7 +2,7 @@
* CL_fx.java
* Copyright (C) 2004
*
- * $Id: CL_fx.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: CL_fx.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.client;
+import jake2.Globals;
import jake2.game.M_Flash;
import jake2.game.entity_state_t;
import jake2.qcommon.Com;
@@ -239,11 +240,10 @@ public class CL_fx extends CL_tent {
===============
*/
static void RunDLights() {
- int i;
cdlight_t[] dl;
dl = cl_dlights;
- for (i = 0; i < MAX_DLIGHTS; i++) {
+ for (int i = 0; i < MAX_DLIGHTS; i++) {
if (dl[i].radius == 0.0f)
continue;
@@ -265,24 +265,20 @@ public class CL_fx extends CL_tent {
static void ParseMuzzleFlash() {
float[] fv = new float[3];
float[] rv = new float[3];
- cdlight_t dl;
- int i, weapon;
- centity_t pl;
- int silenced;
float volume;
String soundname;
- i = MSG.ReadShort(net_message);
+ int i = MSG.ReadShort(net_message);
if (i < 1 || i >= MAX_EDICTS)
Com.Error(ERR_DROP, "CL_ParseMuzzleFlash: bad entity");
- weapon = MSG.ReadByte(net_message);
- silenced = weapon & MZ_SILENCED;
+ int weapon = MSG.ReadByte(net_message);
+ int silenced = weapon & MZ_SILENCED;
weapon &= ~MZ_SILENCED;
- pl = cl_entities[i];
+ centity_t pl = cl_entities[i];
- dl = CL.AllocDlight(i);
+ cdlight_t dl = CL.AllocDlight(i);
VectorCopy(pl.current.origin, dl.origin);
AngleVectors(pl.current.angles, fv, rv, null);
VectorMA(dl.origin, 18, fv, dl.origin);
@@ -513,19 +509,16 @@ public class CL_fx extends CL_tent {
==============
*/
static void ParseMuzzleFlash2() {
- int ent;
float[] origin = new float[3];
- int flash_number;
- cdlight_t dl;
float[] forward = new float[3];
float[] right = new float[3];
String soundname;
- ent = MSG.ReadShort(net_message);
+ int ent = MSG.ReadShort(net_message);
if (ent < 1 || ent >= MAX_EDICTS)
Com.Error(ERR_DROP, "CL_ParseMuzzleFlash2: bad entity");
- flash_number = MSG.ReadByte(net_message);
+ int flash_number = MSG.ReadByte(net_message);
// locate the origin
AngleVectors(cl_entities[ent].current.angles, forward, right, null);
@@ -543,7 +536,7 @@ public class CL_fx extends CL_tent {
+ right[2] * M_Flash.monster_flash_offset[flash_number][1]
+ M_Flash.monster_flash_offset[flash_number][2];
- dl = CL.AllocDlight(ent);
+ cdlight_t dl = CL.AllocDlight(ent);
VectorCopy(origin, dl.origin);
dl.radius = 200 + (rnd.nextInt() & 31);
dl.minlight = 32;
@@ -960,9 +953,8 @@ public class CL_fx extends CL_tent {
*/
static void AddDLights() {
int i;
- cdlight_t[] dl;
-
- dl = cl_dlights;
+
+ cdlight_t[] dl = cl_dlights;
// =====
// PGM
@@ -1059,7 +1051,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1094,7 +1086,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1130,7 +1122,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1197,9 +1189,9 @@ public class CL_fx extends CL_tent {
else
p.color = 0xe0 + (rand() & 7); // yellow
- p.org[0] = org[0] - 16 + frand() * 32;
- p.org[1] = org[1] - 16 + frand() * 32;
- p.org[2] = org[2] - 24 + frand() * 56;
+ p.org[0] = org[0] - 16 + Globals.rnd.nextFloat() * 32;
+ p.org[1] = org[1] - 16 + Globals.rnd.nextFloat() * 32;
+ p.org[2] = org[2] - 24 + Globals.rnd.nextFloat() * 56;
for (j = 0; j < 3; j++)
p.vel[j] = crand() * 20;
@@ -1208,7 +1200,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.3f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1245,7 +1237,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY * 0.2f;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.3f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1278,7 +1270,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + frand() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1320,7 +1312,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = PARTICLE_GRAVITY * 4;
p.alpha = 1.0f;
- p.alphavel = -0.3f / (0.5f + frand() * 0.3f);
+ p.alphavel = -0.3f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1359,7 +1351,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1399,7 +1391,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0xe0;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand();
@@ -1446,7 +1438,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.8f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f);
p.color = 115;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 16;
@@ -1493,7 +1485,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.8f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f);
p.color = color;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 16;
@@ -1557,7 +1549,7 @@ public class CL_fx extends CL_tent {
if ((flags & EF_GIB) != 0) {
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.4f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f);
p.color = 0xe8 + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * orgscale;
@@ -1567,7 +1559,7 @@ public class CL_fx extends CL_tent {
p.vel[2] -= PARTICLE_GRAVITY;
} else if ((flags & EF_GREENGIB) != 0) {
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.4f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.4f);
p.color = 0xdb + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * orgscale;
@@ -1577,7 +1569,7 @@ public class CL_fx extends CL_tent {
p.vel[2] -= PARTICLE_GRAVITY;
} else {
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
p.color = 4 + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * orgscale;
@@ -1635,7 +1627,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0xdc + (rand() & 3);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 5;
@@ -1693,7 +1685,7 @@ public class CL_fx extends CL_tent {
VectorMA(dir, s, up, dir);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
p.color = clr + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + dir[j] * 3;
@@ -1721,7 +1713,7 @@ public class CL_fx extends CL_tent {
VectorClear(p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.6f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0x0 + rand() & 15;
for (j = 0; j < 3; j++) {
@@ -1769,7 +1761,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 0.5f;
- p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0xe4 + (rand() & 3);
for (j = 0; j < 3; j++) {
@@ -1825,7 +1817,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1.0f + frand() * 0.2f);
+ p.alphavel = -1.0f / (1.0f + Globals.rnd.nextFloat() * 0.2f);
p.color = 4 + (rand() & 7);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 2;
@@ -2041,7 +2033,7 @@ public class CL_fx extends CL_tent {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0xe0;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand();
@@ -2127,7 +2119,7 @@ public class CL_fx extends CL_tent {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + frand() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -2138,14 +2130,14 @@ public class CL_fx extends CL_tent {
===============
*/
static void TeleportParticles(float[] org) {
- int i, j, k;
+
cparticle_t p;
float vel;
float[] dir = new float[3];
- for (i = -16; i <= 16; i += 4)
- for (j = -16; j <= 16; j += 4)
- for (k = -16; k <= 32; k += 4) {
+ for (int i = -16; i <= 16; i += 4)
+ for (int j = -16; j <= 16; j += 4)
+ for (int k = -16; k <= 32; k += 4) {
if (free_particles == null)
return;
p = free_particles;
diff --git a/src/jake2/client/CL_newfx.java b/src/jake2/client/CL_newfx.java
index 67abf81..5346226 100644
--- a/src/jake2/client/CL_newfx.java
+++ b/src/jake2/client/CL_newfx.java
@@ -2,7 +2,7 @@
* CL_newfx.java
* Copyright (C) 2004
*
- * $Id: CL_newfx.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
+ * $Id: CL_newfx.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.client;
+import jake2.Globals;
+
/**
* CL_newfx
@@ -171,7 +173,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1 + frand() * 0.5f);
+ p.alphavel = -1.0f / (1 + Globals.rnd.nextFloat() * 0.5f);
p.color = colorStart + (rand() % colorRun);
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 3;
@@ -204,7 +206,7 @@ public class CL_newfx extends CL_fx {
if (free_particles == null)
return;
- if (frand() > 0.3) {
+ if (Globals.rnd.nextFloat() > 0.3) {
p = free_particles;
free_particles = p.next;
p.next = active_particles;
@@ -214,7 +216,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (3.0f + frand() * 0.5f);
+ p.alphavel = -1.0f / (3.0f + Globals.rnd.nextFloat() * 0.5f);
p.color = color;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 3;
@@ -319,7 +321,7 @@ public class CL_newfx extends CL_fx {
// VectorCopy (accel, p.accel);
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * alphavel);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * alphavel);
// p.alphavel = alphavel;
}
}
@@ -360,7 +362,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (1+frand()*0.1f);
+ p.alphavel = -1.0f / (1+Globals.rnd.nextFloat()*0.1f);
p.color = 4 + (rand()&7);
for (j=0 ; j<3 ; j++)
{
@@ -510,7 +512,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY / 2;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -555,7 +557,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY / 2;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
self.nextthink += self.thinkinterval;
}
@@ -773,7 +775,7 @@ public class CL_newfx extends CL_fx {
p.accel[0] = p.accel[1] = 0;
p.alpha = 1.0f;
- p.alphavel = -0.8f / (0.5f + frand() * 0.3f);
+ p.alphavel = -0.8f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -846,7 +848,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.8f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.8f + Globals.rnd.nextFloat() * 0.2f);
p.color = color;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand() * 16;
@@ -887,7 +889,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -0.4f / (0.6f + frand() * 0.2f);
+ p.alphavel = -0.4f / (0.6f + Globals.rnd.nextFloat() * 0.2f);
}
}
@@ -932,7 +934,7 @@ public class CL_newfx extends CL_fx {
p.accel[0] = p.accel[1] = p.accel[2] = 0;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand()*0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat()*0.3f);
}
}
@@ -971,7 +973,7 @@ public class CL_newfx extends CL_fx {
p.accel[2] = -PARTICLE_GRAVITY;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.5f + frand() * 0.3f);
+ p.alphavel = -1.0f / (0.5f + Globals.rnd.nextFloat() * 0.3f);
}
}
@@ -1012,7 +1014,7 @@ public class CL_newfx extends CL_fx {
p.time = cl.time;
p.alpha = 1.0f;
- p.alphavel = -1.0f / (0.3f + frand() * 0.2f);
+ p.alphavel = -1.0f / (0.3f + Globals.rnd.nextFloat() * 0.2f);
p.color = 0xd0;
for (j = 0; j < 3; j++) {
p.org[j] = move[j] + crand();
diff --git a/src/jake2/client/CL_parse.java b/src/jake2/client/CL_parse.java
index d60de21..f636ba0 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.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: CL_parse.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -197,10 +197,9 @@ public class CL_parse extends CL_view {
======================
*/
static void RegisterSounds() {
- int i;
S.BeginRegistration();
CL.RegisterTEntSounds();
- for (i = 1; i < MAX_SOUNDS; i++) {
+ for (int i = 1; i < MAX_SOUNDS; i++) {
if (cl.configstrings[CS_SOUNDS + i] == null || cl.configstrings[CS_SOUNDS + i] == "")
break;
cl.sound_precache[i] = S.RegisterSound(cl.configstrings[CS_SOUNDS + i]);
@@ -217,13 +216,10 @@ public class CL_parse extends CL_view {
=====================
*/
public static void ParseDownload() {
- int size, percent;
- String name;
- int r;
// read the data
- size = MSG.ReadShort(net_message);
- percent = MSG.ReadByte(net_message);
+ int size = MSG.ReadShort(net_message);
+ int percent = MSG.ReadByte(net_message);
if (size == -1) {
Com.Printf("Server does not have this file.\n");
if (cls.download != null) {
@@ -237,7 +233,7 @@ public class CL_parse extends CL_view {
// open the file if not opened yet
if (cls.download == null) {
- name = DownloadFileName(cls.downloadtempname);
+ String name = DownloadFileName(cls.downloadtempname);
FS.CreatePath(name);
@@ -277,7 +273,7 @@ public class CL_parse extends CL_view {
// rename the temp file to it's final name
oldn = DownloadFileName(cls.downloadtempname);
newn = DownloadFileName(cls.downloadname);
- r = Lib.rename(oldn, newn);
+ int r = Lib.rename(oldn, newn);
if (r != 0)
Com.Printf("failed to rename.\n");
diff --git a/src/jake2/client/CL_pred.java b/src/jake2/client/CL_pred.java
index eecf0eb..0b0e2ab 100644
--- a/src/jake2/client/CL_pred.java
+++ b/src/jake2/client/CL_pred.java
@@ -2,7 +2,7 @@
* CL_pred.java
* Copyright (C) 2004
*
- * $Id: CL_pred.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: CL_pred.java,v 1.3 2004-07-08 20:24:28 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -203,14 +203,6 @@ public class CL_pred extends CL_parse {
=================
*/
static void PredictMovement() {
- int ack, current;
- int frame;
- int oldframe;
- usercmd_t cmd;
- pmove_t pm;
- int i;
- int step;
- int oldz;
if (cls.state != ca_active)
return;
@@ -220,14 +212,14 @@ public class CL_pred extends CL_parse {
if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) {
// just set angles
- for (i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]);
}
return;
}
- ack = cls.netchan.incoming_acknowledged;
- current = cls.netchan.outgoing_sequence;
+ int ack = cls.netchan.incoming_acknowledged;
+ int current = cls.netchan.outgoing_sequence;
// if we are too far out of date, just freeze
if (current - ack >= CMD_BACKUP) {
@@ -238,7 +230,7 @@ public class CL_pred extends CL_parse {
// copy current state to pmove
//memset (pm, 0, sizeof(pm));
- pm = new pmove_t();
+ pmove_t pm = new pmove_t();
pm.trace = new pmove_t.TraceAdapter() {
public trace_t trace(float[] start, float[] mins, float[] maxs, float[] end) {
@@ -257,9 +249,10 @@ public class CL_pred extends CL_parse {
pm.s.set(cl.frame.playerstate.pmove);
// SCR_DebugGraph (current - ack - 1, 0);
- frame = 0;
+ int frame = 0;
// run frames
+ usercmd_t cmd;
while (++ack < current) {
frame = ack & (CMD_BACKUP - 1);
cmd = cl.cmds[frame];
@@ -272,9 +265,9 @@ public class CL_pred extends CL_parse {
VectorCopy(pm.s.origin, cl.predicted_origins[frame]);
}
- oldframe = (ack - 2) & (CMD_BACKUP - 1);
- oldz = cl.predicted_origins[oldframe][2];
- step = pm.s.origin[2] - oldz;
+ int oldframe = (ack - 2) & (CMD_BACKUP - 1);
+ int oldz = cl.predicted_origins[oldframe][2];
+ int step = pm.s.origin[2] - oldz;
if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0) {
cl.predicted_step = step * 0.125f;
cl.predicted_step_time = (int) (cls.realtime - cls.frametime * 500);
diff --git a/src/jake2/client/CL_tent.java b/src/jake2/client/CL_tent.java
index 7430a45..939f3ca 100644
--- a/src/jake2/client/CL_tent.java
+++ b/src/jake2/client/CL_tent.java
@@ -2,7 +2,7 @@
* CL_tent.java
* Copyright (C) 2004
*
- * $Id: CL_tent.java,v 1.1 2004-07-07 19:58:40 hzi Exp $
+ * $Id: CL_tent.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -906,7 +906,7 @@ public class CL_tent extends Globals {
ex.lightcolor[2] = 0.5f;
ex.ent.angles[1] = rand() % 360;
ex.ent.model = cl_mod_explo4;
- if (frand() < 0.5)
+ if (Globals.rnd.nextFloat() < 0.5)
ex.baseframe = 15;
ex.frames = 15;
CL.ExplosionParticles(pos);
@@ -934,7 +934,7 @@ public class CL_tent extends Globals {
ex.ent.model = cl_mod_explo4; // PMM
else
ex.ent.model = cl_mod_explo4_big;
- if (frand() < 0.5)
+ if (Globals.rnd.nextFloat() < 0.5)
ex.baseframe = 15;
ex.frames = 15;
if ((type != TE_EXPLOSION1_BIG) && (type != TE_EXPLOSION1_NP)) // PMM
@@ -1107,7 +1107,7 @@ public class CL_tent extends Globals {
ex.lightcolor[2] = 0.5f;
ex.ent.angles[1] = rand() % 360;
ex.ent.model = cl_mod_explo4;
- if (frand() < 0.5)
+ if (Globals.rnd.nextFloat() < 0.5)
ex.baseframe = 15;
ex.frames = 15;
if (type == TE_ROCKET_EXPLOSION_WATER)
diff --git a/src/jake2/client/CL_view.java b/src/jake2/client/CL_view.java
index 2d2e7ab..08e55c3 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.1 2004-07-07 19:58:40 hzi Exp $
+ * $Id: CL_view.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -51,12 +51,14 @@ public class CL_view extends CL_input {
=================
*/
+ private static xcommand_t prepRefreshCallback = new xcommand_t() {
+ public void execute() {
+ PrepRefresh2();
+ }
+ };
+
static void PrepRefresh() {
- re.updateScreen(new xcommand_t() {
- public void execute() {
- PrepRefresh2();
- }
- });
+ re.updateScreen(prepRefreshCallback);
}
static void PrepRefresh2() {
diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java
index 2fe8ed3..0b3e82a 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.2 2004-07-08 15:58:43 hzi Exp $
+ * $Id: Key.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -288,9 +288,7 @@ public class Key extends Globals {
/**
* Called by the system between frames for both key up and key down events.
*/
- public static void Event(int key, boolean down, long time) {
- //System.out.println(key + " " + down);
- //return;
+ public static void Event(int key, boolean down, long time) {
String kb;
String cmd;
@@ -324,14 +322,11 @@ public class Key extends Globals {
shift_down = down;
// console key is hardcoded, so the user can never unbind it
- if (key == '`' || key == '~') {
+ if (key == '#' || key == '~') {
if (!down)
return;
- try {
- Console.ToggleConsole_f.execute();
- }
- catch (Exception e) {
- }
+
+ Console.ToggleConsole_f.execute();
return;
}
diff --git a/src/jake2/client/M.java b/src/jake2/client/M.java
index 86747f8..dd8304f 100644
--- a/src/jake2/client/M.java
+++ b/src/jake2/client/M.java
@@ -2,7 +2,7 @@
* M.java
* Copyright (C) 2003
*
- * $Id: M.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: M.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.client;
import jake2.Defines;
+import jake2.Globals;
import jake2.game.*;
import jake2.qcommon.Com;
import jake2.server.SV;
@@ -393,7 +394,7 @@ public final class M
if (0 == (ent.svflags & Defines.SVF_DEADMONSTER))
{
if ((ent.watertype & Defines.CONTENTS_LAVA) != 0)
- if (Lib.random() <= 0.5)
+ if (Globals.rnd.nextFloat() <= 0.5)
GameBase.gi.sound(ent, Defines.CHAN_BODY, GameBase.gi.soundindex("player/lava1.wav"), 1, Defines.ATTN_NORM, 0);
else
GameBase.gi.sound(ent, Defines.CHAN_BODY, GameBase.gi.soundindex("player/lava2.wav"), 1, Defines.ATTN_NORM, 0);
@@ -629,11 +630,11 @@ public final class M
if (self.waterlevel != 0)
return true;
- if (Lib.random() > 0.5)
+ if (Globals.rnd.nextFloat() > 0.5)
return true;
self.think = M_FliesOn;
- self.nextthink = GameBase.level.time + 5 + 10 * Lib.random();
+ self.nextthink = GameBase.level.time + 5 + 10 * Globals.rnd.nextFloat();
return true;
}
};
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index 8363f6e..6a426d1 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.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: SCR.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -84,7 +84,6 @@ public final class SCR extends Globals
static cvar_t scr_graphshift;
static cvar_t scr_drawall;
static cvar_t fps;
- static cvar_t fps_updates;
static dirty_t scr_dirty = new dirty_t();
static dirty_t[] scr_old_dirty = { new dirty_t(), new dirty_t()};
@@ -436,7 +435,6 @@ public final class SCR extends Globals
scr_graphshift = Cvar.Get("graphshift", "0", 0);
scr_drawall = Cvar.Get("scr_drawall", "1", 0);
fps = Cvar.Get("fps", "0", 0);
- fps_updates = Cvar.Get("fps_updates", "1", 0);
//
// register our commands
@@ -1421,10 +1419,16 @@ public final class SCR extends Globals
crosshair_pic);
}
+ private static xcommand_t updateScreenCallback = new xcommand_t() {
+ public void execute() {
+ UpdateScreen2();
+ }
+ };
+
// wird anstelle von der richtigen UpdateScreen benoetigt
public static void UpdateScreen()
{
- Globals.re.updateScreen(null);
+ Globals.re.updateScreen(updateScreenCallback);
}
/*
diff --git a/src/jake2/client/SND_DMA.java b/src/jake2/client/SND_DMA.java
index dc487d8..0409e8b 100644
--- a/src/jake2/client/SND_DMA.java
+++ b/src/jake2/client/SND_DMA.java
@@ -2,7 +2,7 @@
* S_DMA.java
* Copyright (C) 2004
*
- * $Id: SND_DMA.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: SND_DMA.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -28,6 +28,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.client;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.Arrays;
+
+import jake2.game.*;
import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
@@ -62,21 +67,22 @@ public class SND_DMA extends SND_MIX {
//
static int s_registration_sequence;
//
-// channel_t channels[MAX_CHANNELS];
+ static channel_t[] channels = new channel_t[MAX_CHANNELS];
+ static {
+ for(int i=0; i < MAX_CHANNELS; i++)
+ channels[i] = new channel_t();
+ }
//
// qboolean snd_initialized = false;
static boolean sound_started = false;
-//
+ static float[] listener_origin = {0, 0, 0};
+ static float[] listener_forward = {0, 0, 0};
+ static float[] listener_right = {0, 0, 0};
+ static float[] listener_up = {0, 0, 0};
-//
-// vec3_t listener_origin;
-// vec3_t listener_forward;
-// vec3_t listener_right;
-// vec3_t listener_up;
-//
static boolean s_registering;
-//
+
static int soundtime; // sample PAIRS
static int paintedtime; // sample PAIRS
//
@@ -92,14 +98,18 @@ public class SND_DMA extends SND_MIX {
}
static int num_sfx;
//
-// #define MAX_PLAYSOUNDS 128
-// playsound_t s_playsounds[MAX_PLAYSOUNDS];
-// playsound_t s_freeplays;
-// playsound_t s_pendingplays;
-//
-// int s_beginofs;
-//
- static cvar_t s_volume;
+ static final int MAX_PLAYSOUNDS = 128;
+ static playsound_t[] s_playsounds = new playsound_t[MAX_PLAYSOUNDS];
+ static {
+ for( int i = 0; i < MAX_PLAYSOUNDS; i++) {
+ s_playsounds[i] = new playsound_t();
+ }
+ }
+ static playsound_t s_freeplays = new playsound_t();
+ static playsound_t s_pendingplays = new playsound_t();
+
+ static int s_beginofs;
+
static cvar_t s_testsound;
static cvar_t s_loadas8bit;
static cvar_t s_khz;
@@ -141,7 +151,7 @@ public class SND_DMA extends SND_MIX {
Com.Printf("\n------- sound initialization -------\n");
- cv = Cvar.Get("s_initsound", "1", 0);
+ cv = Cvar.Get("s_initsound", "0", 0);
if (cv.value == 0.0f)
Com.Printf("not initializing.\n");
else {
@@ -189,7 +199,7 @@ public class SND_DMA extends SND_MIX {
S.StopAllSounds();
}
-S.SoundInfo_f();
+
Com.Printf("------------------------------------\n");
}
@@ -198,10 +208,9 @@ S.SoundInfo_f();
// Shutdown sound engine
// =======================================================================
- static void Shutdown()
- {
- int i;
- sfx_t[] sfx;
+ static void Shutdown() {
+ int i;
+ sfx_t[] sfx;
if (!sound_started)
return;
@@ -216,8 +225,7 @@ S.SoundInfo_f();
Cmd.RemoveCommand("soundinfo");
// free all sounds
- for (i=0, sfx=known_sfx ; i < num_sfx ; i++)
- {
+ for (i = 0, sfx = known_sfx; i < num_sfx; i++) {
if (sfx[i].name == null)
continue;
@@ -281,15 +289,15 @@ S.SoundInfo_f();
}
//
//
-// /*
-// ==================
-// S_AliasName
-//
-// ==================
-// */
-// sfx_t *S_AliasName (char *aliasname, char *truename)
-// {
-// sfx_t *sfx;
+ /*
+ ==================
+ S_AliasName
+
+ ==================
+ */
+ static sfx_t AliasName(String aliasname, String truename)
+ {
+ sfx_t sfx = null;
// char *s;
// int i;
//
@@ -314,10 +322,10 @@ S.SoundInfo_f();
// sfx->registration_sequence = s_registration_sequence;
// sfx->truename = s;
//
-// return sfx;
-// }
-//
-//
+ return sfx;
+ }
+
+
/*
=====================
S_BeginRegistration
@@ -338,14 +346,14 @@ S.SoundInfo_f();
static sfx_t RegisterSound(String name) {
sfx_t sfx = null;
-// if (!sound_started)
-// return null;
-//
-// sfx = S.FindName(name, true);
-// sfx.registration_sequence = s_registration_sequence;
-//
-// if (!s_registering)
-// S.LoadSound(sfx);
+ if (!sound_started)
+ return null;
+
+ sfx = S.FindName(name, true);
+ sfx.registration_sequence = s_registration_sequence;
+
+ if (!s_registering)
+ S.LoadSound(sfx);
return sfx;
}
@@ -357,43 +365,39 @@ S.SoundInfo_f();
=====================
*/
- static void EndRegistration ()
- {
-// int i;
-// sfx_t *sfx;
-// int size;
-//
-// // free any sounds not from this registration sequence
-// for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
-// {
-// if (!sfx->name[0])
-// continue;
-// if (sfx->registration_sequence != s_registration_sequence)
-// { // don't need this sound
-// if (sfx->cache) // it is possible to have a leftover
-// Z_Free (sfx->cache); // from a server that didn't finish loading
-// memset (sfx, 0, sizeof(*sfx));
-// }
-// else
-// { // make sure it is paged in
-// if (sfx->cache)
-// {
-// size = sfx->cache->length*sfx->cache->width;
-// Com_PageInMemory ((byte *)sfx->cache, size);
-// }
-// }
-//
-// }
-//
-// // load everything in
-// for (i=0, sfx=known_sfx ; i < num_sfx ; i++,sfx++)
-// {
-// if (!sfx->name[0])
-// continue;
-// S_LoadSound (sfx);
-// }
-//
-// s_registering = false;
+ static void EndRegistration() {
+ int i;
+ sfx_t sfx;
+ int size;
+
+ // free any sounds not from this registration sequence
+ for (i = 0; i < num_sfx; i++) {
+ sfx = known_sfx[i];
+ if (sfx.name == null)
+ continue;
+ if (sfx.registration_sequence != s_registration_sequence) { // don't need this sound
+ //memset (sfx, 0, sizeof(*sfx));
+ sfx.clear();
+ } else {
+ // make sure it is paged in
+ // if (sfx->cache)
+ // {
+ // size = sfx->cache->length*sfx->cache->width;
+ // Com_PageInMemory ((byte *)sfx->cache, size);
+ // }
+ }
+
+ }
+
+ // load everything in
+ for (i = 0; i < num_sfx; i++) {
+ sfx = known_sfx[i];
+ if (sfx.name == null)
+ continue;
+ S.LoadSound(sfx);
+ }
+
+ s_registering = false;
}
//
//
@@ -506,8 +510,8 @@ S.SoundInfo_f();
// S_Spatialize
// =================
// */
-// void S_Spatialize(channel_t *ch)
-// {
+ static void Spatialize(channel_t ch)
+ {
// vec3_t origin;
//
// // anything coming from the view entity will always be full volume
@@ -526,28 +530,27 @@ S.SoundInfo_f();
// CL_GetEntitySoundOrigin (ch->entnum, origin);
//
// S_SpatializeOrigin (origin, ch->master_vol, ch->dist_mult, &ch->leftvol, &ch->rightvol);
-// }
-//
-//
-// /*
-// =================
-// S_AllocPlaysound
-// =================
-// */
-// playsound_t *S_AllocPlaysound (void)
-// {
-// playsound_t *ps;
-//
-// ps = s_freeplays.next;
-// if (ps == &s_freeplays)
-// return NULL; // no free playsounds
-//
-// // unlink from freelist
-// ps->prev->next = ps->next;
-// ps->next->prev = ps->prev;
-//
-// return ps;
-// }
+ }
+
+ /*
+ =================
+ S_AllocPlaysound
+ =================
+ */
+ static playsound_t AllocPlaysound ()
+ {
+ playsound_t ps;
+
+ ps = s_freeplays.next;
+ if (ps == s_freeplays)
+ return null; // no free playsounds
+
+ // unlink from freelist
+ ps.prev.next = ps.next;
+ ps.next.prev = ps.prev;
+
+ return ps;
+ }
//
//
// /*
@@ -615,66 +618,61 @@ S.SoundInfo_f();
// // free the playsound
// S_FreePlaysound (ps);
// }
-//
-// struct sfx_s *S_RegisterSexedSound (entity_state_t *ent, char *base)
-// {
-// int n;
-// char *p;
-// struct sfx_s *sfx;
-// FILE *f;
-// char model[MAX_QPATH];
-// char sexedFilename[MAX_QPATH];
-// char maleFilename[MAX_QPATH];
-//
-// // determine what model the client is using
-// model[0] = 0;
-// n = CS_PLAYERSKINS + ent->number - 1;
-// if (cl.configstrings[n][0])
-// {
-// p = strchr(cl.configstrings[n], '\\');
-// if (p)
-// {
-// p += 1;
-// strcpy(model, p);
-// p = strchr(model, '/');
-// if (p)
-// *p = 0;
-// }
-// }
-// // if we can't figure it out, they're male
-// if (!model[0])
-// strcpy(model, "male");
-//
-// // see if we already know of the model specific sound
-// Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
-// sfx = S_FindName (sexedFilename, false);
-//
-// if (!sfx)
-// {
-// // no, so see if it exists
-// FS_FOpenFile (&sexedFilename[1], &f);
-// if (f)
-// {
-// // yes, close the file and register it
-// FS_FCloseFile (f);
-// sfx = S_RegisterSound (sexedFilename);
-// }
-// else
-// {
-// // no, revert to the male sound in the pak0.pak
-// Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
-// sfx = S_AliasName (sexedFilename, maleFilename);
-// }
-// }
-//
-// return sfx;
-// }
-//
-//
-//// =======================================================================
-//// Start a sound effect
-//// =======================================================================
-//
+
+ static sfx_t RegisterSexedSound(entity_state_t ent, String base) {
+ sfx_t sfx = null;
+
+ // determine what model the client is using
+ String model = "male";
+ int n = CS_PLAYERSKINS + ent.number - 1;
+ if (cl.configstrings[n] != null) {
+ int p = cl.configstrings[n].indexOf('\\');
+ if (p >= 0) {
+ p++;
+ model = cl.configstrings[n].substring(p);
+ //strcpy(model, p);
+ p = model.indexOf('/');
+ if (p > 0)
+ model = model.substring(0, p - 1);
+ }
+ }
+ // if we can't figure it out, they're male
+ if (model == null || model.length() == 0)
+ model = "male";
+
+ // see if we already know of the model specific sound
+ String sexedFilename = "#players/" + model + "/" + base.substring(1);
+ //Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
+ sfx = S.FindName(sexedFilename, false);
+
+ if (sfx == null) {
+ // no, so see if it exists
+ RandomAccessFile f = null;
+ try {
+ f = FS.FOpenFile(sexedFilename.substring(1));
+ } catch (IOException e) {}
+ if (f != null) {
+ // yes, close the file and register it
+ try {
+ FS.FCloseFile(f);
+ } catch (IOException e1) {}
+ sfx = S.RegisterSound(sexedFilename);
+ } else {
+ // no, revert to the male sound in the pak0.pak
+ //Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
+ String maleFilename = "player/male/" + base.substring(1);
+ sfx = S.AliasName(sexedFilename, maleFilename);
+ }
+ }
+
+ return sfx;
+ }
+
+
+// =======================================================================
+// Start a sound effect
+// =======================================================================
+
/*
====================
S_StartSound
@@ -684,130 +682,115 @@ S.SoundInfo_f();
Entchannel 0 will never override a playing sound
====================
*/
- static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs)
- {
-// sfxcache_t *sc;
-// int vol;
-// playsound_t *ps, *sort;
-// int start;
-//
-// if (!sound_started)
-// return;
-//
-// if (!sfx)
-// return;
-//
-// if (sfx->name[0] == '*')
-// sfx = S_RegisterSexedSound(&cl_entities[entnum].current, sfx->name);
-//
-// // make sure the sound is loaded
-// sc = S_LoadSound (sfx);
-// if (!sc)
-// return; // couldn't load the sound's data
-//
-// vol = fvol*255;
-//
-// // make the playsound_t
-// ps = S_AllocPlaysound ();
-// if (!ps)
-// return;
-//
-// if (origin)
-// {
-// VectorCopy (origin, ps->origin);
-// ps->fixed_origin = true;
-// }
-// else
-// ps->fixed_origin = false;
-//
-// ps->entnum = entnum;
-// ps->entchannel = entchannel;
-// ps->attenuation = attenuation;
-// ps->volume = vol;
-// ps->sfx = sfx;
-//
-// // drift s_beginofs
-// start = cl.frame.servertime * 0.001 * dma.speed + s_beginofs;
-// if (start < paintedtime)
-// {
-// start = paintedtime;
-// s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
-// }
-// else if (start > paintedtime + 0.3 * dma.speed)
-// {
-// start = paintedtime + 0.1 * dma.speed;
-// s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
-// }
-// else
-// {
-// s_beginofs-=10;
-// }
-//
-// if (!timeofs)
-// ps->begin = paintedtime;
-// else
-// ps->begin = start + timeofs * dma.speed;
-//
-// // sort into the pending sound list
-// for (sort = s_pendingplays.next ;
-// sort != &s_pendingplays && sort->begin < ps->begin ;
-// sort = sort->next)
-// ;
-//
-// ps->next = sort;
-// ps->prev = sort->prev;
-//
-// ps->next->prev = ps;
-// ps->prev->next = ps;
+ static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
+
+ if (!sound_started)
+ return;
+
+ if (sfx == null)
+ return;
+
+ if (sfx.name.charAt(0) == '*')
+ sfx = S.RegisterSexedSound(cl_entities[entnum].current, sfx.name);
+
+ // make sure the sound is loaded
+ sfxcache_t sc = S.LoadSound(sfx);
+ if (sc == null)
+ return; // couldn't load the sound's data
+
+ int vol = (int) (fvol * 255);
+
+ // make the playsound_t
+ playsound_t ps = S.AllocPlaysound();
+ if (ps == null)
+ return;
+
+ if (origin != null) {
+ VectorCopy(origin, ps.origin);
+ ps.fixed_origin = true;
+ } else
+ ps.fixed_origin = false;
+
+ ps.entnum = entnum;
+ ps.entchannel = entchannel;
+ ps.attenuation = attenuation;
+ ps.volume = vol;
+ ps.sfx = sfx;
+
+ // drift s_beginofs
+ int start = (int) (cl.frame.servertime * 0.001f * dma.speed + s_beginofs);
+ if (start < paintedtime) {
+ start = paintedtime;
+ s_beginofs = (int) (start - (cl.frame.servertime * 0.001f * dma.speed));
+ } else if (start > paintedtime + 0.3f * dma.speed) {
+ start = (int) (paintedtime + 0.1f * dma.speed);
+ s_beginofs = (int) (start - (cl.frame.servertime * 0.001f * dma.speed));
+ } else {
+ s_beginofs -= 10;
+ }
+
+ if (timeofs == 0.0f)
+ ps.begin = paintedtime;
+ else
+ ps.begin = (long) (start + timeofs * dma.speed);
+
+ // sort into the pending sound list
+ playsound_t sort;
+ for (sort = s_pendingplays.next; sort != s_pendingplays && sort.begin < ps.begin; sort = sort.next);
+
+ ps.next = sort;
+ ps.prev = sort.prev;
+
+ ps.next.prev = ps;
+ ps.prev.next = ps;
}
-//
-// /*
-// ==================
-// S_StartLocalSound
-// ==================
-// */
+ /*
+ ==================
+ S_StartLocalSound
+ ==================
+ */
static void StartLocalSound(String sound) {
-// sfx_t *sfx;
-//
-// if (!sound_started)
-// return;
-//
-// sfx = S_RegisterSound (sound);
-// if (!sfx)
-// {
-// Com_Printf ("S_StartLocalSound: can't cache %s\n", sound);
-// return;
-// }
-// S_StartSound (NULL, cl.playernum+1, 0, sfx, 1, 1, 0);
+ sfx_t sfx;
+
+ if (!sound_started)
+ return;
+
+ sfx = S.RegisterSound(sound);
+ if (sfx == null) {
+ Com.Printf("S_StartLocalSound: can't cache " + sound + "\n");
+ return;
+ }
+ S.StartSound(null, cl.playernum + 1, 0, sfx, 1, 1, 0);
}
-//
-//
-// /*
-// ==================
-// S_ClearBuffer
-// ==================
-// */
-// void S_ClearBuffer (void)
-// {
-// int clear;
-//
-// if (!sound_started)
-// return;
-//
-// s_rawend = 0;
-//
-// if (dma.samplebits == 8)
-// clear = 0x80;
-// else
-// clear = 0;
-//
-// SNDDMA_BeginPainting ();
-// if (dma.buffer)
-// memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
-// SNDDMA_Submit ();
-// }
-//
+
+
+ /*
+ ==================
+ S_ClearBuffer
+ ==================
+ */
+ static void ClearBuffer()
+ {
+ int clear;
+
+ if (!sound_started)
+ return;
+
+ s_rawend = 0;
+
+ if (dma.samplebits == 8)
+ clear = 0x80;
+ else
+ clear = 0;
+
+ SNDDMA_BeginPainting ();
+ if (dma.buffer != null)
+ //memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
+ Arrays.fill(dma.buffer, (byte)clear);
+ SNDDMA_Submit ();
+ }
+
/*
==================
S_StopAllSounds
@@ -815,41 +798,44 @@ S.SoundInfo_f();
*/
static void StopAllSounds()
{
-// int i;
-//
-// if (!sound_started)
-// return;
-//
-// // clear all the playsounds
-// memset(s_playsounds, 0, sizeof(s_playsounds));
-// s_freeplays.next = s_freeplays.prev = &s_freeplays;
-// s_pendingplays.next = s_pendingplays.prev = &s_pendingplays;
-//
-// for (i=0 ; i<MAX_PLAYSOUNDS ; i++)
-// {
-// s_playsounds[i].prev = &s_freeplays;
-// s_playsounds[i].next = s_freeplays.next;
-// s_playsounds[i].prev->next = &s_playsounds[i];
-// s_playsounds[i].next->prev = &s_playsounds[i];
-// }
-//
-// // clear all the channels
-// memset(channels, 0, sizeof(channels));
-//
-// S_ClearBuffer ();
+ int i;
+
+ if (!sound_started)
+ return;
+
+ // clear all the playsounds
+ //memset(s_playsounds, 0, sizeof(s_playsounds));
+ s_freeplays.next = s_freeplays.prev = s_freeplays;
+ s_pendingplays.next = s_pendingplays.prev = s_pendingplays;
+
+ for (i=0 ; i<MAX_PLAYSOUNDS ; i++)
+ {
+ s_playsounds[i].clear();
+ s_playsounds[i].prev = s_freeplays;
+ s_playsounds[i].next = s_freeplays.next;
+ s_playsounds[i].prev.next = s_playsounds[i];
+ s_playsounds[i].next.prev = s_playsounds[i];
+ }
+
+ // clear all the channels
+ //memset(channels, 0, sizeof(channels));
+ for (i = 0; i < MAX_CHANNELS; i++)
+ channels[i].clear();
+
+ S.ClearBuffer();
}
//
-// /*
-// ==================
-// S_AddLoopSounds
-//
-// Entities with a ->sound field will generated looped sounds
-// that are automatically started, stopped, and merged together
-// as the entities are sent to the client
-// ==================
-// */
-// void S_AddLoopSounds (void)
-// {
+ /*
+ ==================
+ S_AddLoopSounds
+
+ Entities with a ->sound field will generated looped sounds
+ that are automatically started, stopped, and merged together
+ as the entities are sent to the client
+ ==================
+ */
+ static void AddLoopSounds()
+ {
// int i, j;
// int sounds[MAX_EDICTS];
// int left, right, left_total, right_total;
@@ -927,7 +913,7 @@ S.SoundInfo_f();
// ch->pos = paintedtime % sc->length;
// ch->end = paintedtime + sc->length - ch->pos;
// }
-// }
+ }
//
//// =============================================================================
//
@@ -1029,84 +1015,79 @@ S.SoundInfo_f();
// }
//
//// =============================================================================
-//
-// /*
-// ============
-// S_Update
-//
-// Called once each time through the main loop
-// ============
-// */
+
+ /*
+ ============
+ S_Update
+
+ Called once each time through the main loop
+ ============
+ */
static void Update(float[] origin, float[] forward, float[] right, float[] up) {
-// int i;
-// int total;
-// channel_t *ch;
-// channel_t *combine;
-//
-// if (!sound_started)
-// return;
-//
-// // if the laoding plaque is up, clear everything
-// // out to make sure we aren't looping a dirty
-// // dma buffer while loading
-// if (cls.disable_screen)
-// {
-// S_ClearBuffer ();
-// return;
-// }
-//
-// // rebuild scale tables if volume is modified
-// if (s_volume->modified)
-// S_InitScaletable ();
-//
-// VectorCopy(origin, listener_origin);
-// VectorCopy(forward, listener_forward);
-// VectorCopy(right, listener_right);
-// VectorCopy(up, listener_up);
-//
-// combine = NULL;
-//
-// // update spatialization for dynamic sounds
-// ch = channels;
-// for (i=0 ; i<MAX_CHANNELS; i++, ch++)
-// {
-// if (!ch->sfx)
-// continue;
-// if (ch->autosound)
-// { // autosounds are regenerated fresh each frame
-// memset (ch, 0, sizeof(*ch));
-// continue;
-// }
-// S_Spatialize(ch); // respatialize channel
-// if (!ch->leftvol && !ch->rightvol)
-// {
-// memset (ch, 0, sizeof(*ch));
-// continue;
-// }
-// }
-//
-// // add loopsounds
-// S_AddLoopSounds ();
-//
-// //
-// // debugging output
-// //
-// if (s_show->value)
-// {
-// total = 0;
-// ch = channels;
-// for (i=0 ; i<MAX_CHANNELS; i++, ch++)
-// if (ch->sfx && (ch->leftvol || ch->rightvol) )
-// {
-// Com_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name);
-// total++;
-// }
-//
-// Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
-// }
-//
-//// mix some sound
-// S_Update_();
+
+ if (!sound_started)
+ return;
+
+ // if the laoding plaque is up, clear everything
+ // out to make sure we aren't looping a dirty
+ // dma buffer while loading
+ if (cls.disable_screen != 0.0f) {
+ S.ClearBuffer();
+ return;
+ }
+
+ // rebuild scale tables if volume is modified
+ if (s_volume.modified)
+ S.InitScaletable();
+
+ VectorCopy(origin, listener_origin);
+ VectorCopy(forward, listener_forward);
+ VectorCopy(right, listener_right);
+ VectorCopy(up, listener_up);
+
+ channel_t combine = null;
+
+ // update spatialization for dynamic sounds
+ channel_t ch;
+ for (int i = 0; i < MAX_CHANNELS; i++) {
+ ch = channels[i];
+ if (ch.sfx == null)
+ continue;
+ if (ch.autosound) { // autosounds are regenerated fresh each frame
+ //memset (ch, 0, sizeof(*ch));
+ ch.clear();
+ continue;
+ }
+ S.Spatialize(ch); // respatialize channel
+ if (ch.leftvol == 0 && ch.rightvol == 0) {
+ //memset (ch, 0, sizeof(*ch));
+ ch.clear();
+ continue;
+ }
+ }
+
+ // add loopsounds
+ S.AddLoopSounds();
+
+ //
+ // debugging output
+ //
+ if (s_show.value != 0.0f) {
+ int total = 0;
+
+ for (int i = 0; i < MAX_CHANNELS; i++) {
+ ch = channels[i];
+ if (ch.sfx != null && (ch.leftvol != 0 || ch.rightvol != 0)) {
+ Com.Printf(ch.leftvol + " " + ch.rightvol + " " + ch.sfx.name + "\n");
+ total++;
+ }
+ }
+
+ Com.Printf("----(" + total + ")---- painted: " + paintedtime + "\n");
+ }
+
+ // mix some sound
+ S.Update_();
}
//
@@ -1140,8 +1121,8 @@ S.SoundInfo_f();
// }
//
//
-// void S_Update_(void)
-// {
+ static void Update_()
+ {
// unsigned endtime;
// int samps;
//
@@ -1177,8 +1158,8 @@ S.SoundInfo_f();
// S_PaintChannels (endtime);
//
// SNDDMA_Submit ();
-// }
-//
+ }
+
/*
===============================================================================
@@ -1187,59 +1168,51 @@ S.SoundInfo_f();
===============================================================================
*/
- static void Play()
- {
-// int i;
-// char name[256];
-// sfx_t *sfx;
-//
-// i = 1;
-// while (i<Cmd_Argc())
-// {
-// if (!strrchr(Cmd_Argv(i), '.'))
-// {
-// strcpy(name, Cmd_Argv(i));
-// strcat(name, ".wav");
-// }
-// else
-// strcpy(name, Cmd_Argv(i));
-// sfx = S_RegisterSound(name);
-// S_StartSound(NULL, cl.playernum+1, 0, sfx, 1.0, 1.0, 0);
-// i++;
-// }
+ static void Play() {
+ int i;
+ String name;
+ sfx_t sfx;
+
+ i = 1;
+ while (i < Cmd.Argc()) {
+ name = new String(Cmd.Argv(i));
+ if (name.indexOf('.') == -1)
+ name += ".wav";
+
+ sfx = S.RegisterSound(name);
+ S.StartSound(null, cl.playernum + 1, 0, sfx, 1.0f, 1.0f, 0.0f);
+ i++;
+ }
}
-//
+
static void SoundList() {
-// int i;
-// sfx_t *sfx;
-// sfxcache_t *sc;
-// int size, total;
-//
-// total = 0;
-// for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
-// {
-// if (!sfx->registration_sequence)
-// continue;
-// sc = sfx->cache;
-// if (sc)
-// {
-// size = sc->length*sc->width*(sc->stereo+1);
-// total += size;
-// if (sc->loopstart >= 0)
-// Com_Printf ("L");
-// else
-// Com_Printf (" ");
-// Com_Printf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name);
-// }
-// else
-// {
-// if (sfx->name[0] == '*')
-// Com_Printf(" placeholder : %s\n", sfx->name);
-// else
-// Com_Printf(" not loaded : %s\n", sfx->name);
-// }
-// }
-// Com_Printf ("Total resident: %i\n", total);
+ int i;
+ sfx_t sfx;
+ sfxcache_t sc;
+ int size, total;
+
+ total = 0;
+ for (i = 0; i < num_sfx; i++) {
+ sfx = known_sfx[i];
+ if (sfx.registration_sequence == 0)
+ continue;
+ sc = sfx.cache;
+ if (sc != null) {
+ size = sc.length * sc.width * (sc.stereo + 1);
+ total += size;
+ if (sc.loopstart >= 0)
+ Com.Printf("L");
+ else
+ Com.Printf(" ");
+ Com.Printf("(%2db) %6i : %s\n", new Vargs(3).add(sc.width * 8).add(size).add(sfx.name));
+ } else {
+ if (sfx.name.charAt(0) == '*')
+ Com.Printf(" placeholder : " + sfx.name + "\n");
+ else
+ Com.Printf(" not loaded : " + sfx.name + "\n");
+ }
+ }
+ Com.Printf("Total resident: " + total + "\n");
}
}
diff --git a/src/jake2/client/SND_JAVA.java b/src/jake2/client/SND_JAVA.java
index 3853e09..ddfa020 100644
--- a/src/jake2/client/SND_JAVA.java
+++ b/src/jake2/client/SND_JAVA.java
@@ -2,7 +2,7 @@
* SND_JAVA.java
* Copyright (C) 2004
*
- * $Id: SND_JAVA.java,v 1.1 2004-07-07 19:58:51 hzi Exp $
+ * $Id: SND_JAVA.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -146,7 +146,7 @@ public class SND_JAVA extends Globals {
runLine();
}
- void SNDDMA_BeginPainting() {}
+ static void SNDDMA_BeginPainting() {}
private static int pos = 0;
static void runLine() {
diff --git a/src/jake2/client/SND_MIX.java b/src/jake2/client/SND_MIX.java
index 9ba7747..39f80a2 100644
--- a/src/jake2/client/SND_MIX.java
+++ b/src/jake2/client/SND_MIX.java
@@ -2,7 +2,7 @@
* SND_MIX.java
* Copyright (C) 2004
*
- * $Id: SND_MIX.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+ * $Id: SND_MIX.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -25,11 +25,62 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.client;
+import jake2.game.cvar_t;
+import jake2.util.Math3D;
+
/**
* SND_MIX
*/
public class SND_MIX extends SND_MEM {
+ static final int MAX_CHANNELS = 32;
+
+ static class playsound_t {
+ playsound_t prev, next;
+ sfx_t sfx;
+ float volume;
+ float attenuation;
+ int entnum;
+ int entchannel;
+ boolean fixed_origin; // use origin field instead of entnum's origin
+ float[] origin = { 0, 0, 0 };
+ long begin; // begin on this sample
+
+ public void clear() {
+ prev = next = null;
+ sfx = null;
+ volume = attenuation = begin = entnum = entchannel = 0;
+ fixed_origin = false;
+ Math3D.VectorClear(origin);
+ }
+ };
+
+ static class channel_t {
+ sfx_t sfx; // sfx number
+ int leftvol; // 0-255 volume
+ int rightvol; // 0-255 volume
+ int end; // end time in global paintsamples
+ int pos; // sample position in sfx
+ int looping; // where to loop, -1 = no looping OBSOLETE?
+ int entnum; // to allow overriding a specific sound
+ int entchannel; //
+ float[] origin = { 0, 0, 0 }; // only use if fixed_origin is set
+ float[] dist_mult = { 0, 0, 0 }; // distance multiplier (attenuation/clipK)
+ int master_vol; // 0-255 master volume
+ boolean fixed_origin; // use origin instead of fetching entnum's origin
+ boolean autosound; // from an entity->sound, cleared each frame
+
+ void clear() {
+ sfx = null;
+ leftvol = rightvol = end = pos = looping = entnum = entchannel = master_vol = 0;
+ Math3D.VectorClear(origin);
+ Math3D.VectorClear(dist_mult);
+ fixed_origin = autosound = false;
+ }
+ };
+
+ static cvar_t s_volume;
+ static int s_rawend;
//// snd_mix.c -- portable code to mix sounds for snd_dma.c
//
// #include "client.h"
@@ -37,7 +88,7 @@ public class SND_MIX extends SND_MEM {
//
// #define PAINTBUFFER_SIZE 2048
// portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
-// int snd_scaletable[32][256];
+ static int[][] snd_scaletable = new int[32][256];
// int *snd_p, snd_linear_count, snd_vol;
// short *snd_out;
//
@@ -360,18 +411,18 @@ public class SND_MIX extends SND_MEM {
// }
// }
//
- static void InitScaletable()
+ static void InitScaletable ()
{
-// int i, j;
-// int scale;
-//
-// s_volume->modified = false;
-// for (i=0 ; i<32 ; i++)
-// {
-// scale = i * 8 * 256 * s_volume->value;
-// for (j=0 ; j<256 ; j++)
-// snd_scaletable[i][j] = ((signed char)j) * scale;
-// }
+ int i, j;
+ int scale;
+
+ s_volume.modified = false;
+ for (i=0 ; i<32 ; i++)
+ {
+ scale = (int)(i * 8 * 256 * s_volume.value);
+ for (j=0 ; j<256 ; j++)
+ snd_scaletable[i][j] = ((byte)j) * scale;
+ }
}
//
//
@@ -509,5 +560,6 @@ public class SND_MIX extends SND_MEM {
//
// ch->pos += count;
// }
-
-}
+//
+//
+} \ No newline at end of file
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index 7b71830..2b8cb81 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.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: VID.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -264,10 +264,6 @@ public class VID extends Globals {
public void Vid_NewWindow(int width, int height) {
VID.NewWindow(width, height);
}
-
- public void updateScreenCallback() {
- SCR.UpdateScreen2();
- }
};
Globals.re = Renderer.getDriver( name, ri );
diff --git a/src/jake2/client/refimport_t.java b/src/jake2/client/refimport_t.java
index f465482..849b143 100644
--- a/src/jake2/client/refimport_t.java
+++ b/src/jake2/client/refimport_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: refimport_t.java,v 1.1 2004-07-07 19:58:52 hzi Exp $
+// $Id: refimport_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
package jake2.client;
@@ -67,10 +67,4 @@ public interface refimport_t {
boolean Vid_GetModeInfo(Dimension dim /* int *w, *h */, int mode);
void Vid_MenuInit();
void Vid_NewWindow(int width, int height);
-
- /**
- * This is the callback for Renderer.
- */
- void updateScreenCallback();
-
} \ No newline at end of file
diff --git a/src/jake2/client/sfx_t.java b/src/jake2/client/sfx_t.java
index 359b40f..71ab344 100644
--- a/src/jake2/client/sfx_t.java
+++ b/src/jake2/client/sfx_t.java
@@ -2,7 +2,13 @@
* sfx_t.java
* Copyright (C) 2003
*
- * $Id: sfx_t.java,v 1.2 2004-07-08 15:58:42 hzi Exp $
+ * $Id: sfx_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
+ */
+/*
+ * sfx_t.java
+ * Copyright (C) 2004
+ *
+ * $Id: sfx_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -33,6 +39,7 @@ public class sfx_t {
int registration_sequence;
sfxcache_t cache; //ptr
String truename; //ptr
+
public void clear() {
name = truename = null;
cache = null;
diff --git a/src/jake2/game/GameAIAdapters.java b/src/jake2/game/GameAIAdapters.java
index ea20995..465e4a3 100644
--- a/src/jake2/game/GameAIAdapters.java
+++ b/src/jake2/game/GameAIAdapters.java
@@ -19,11 +19,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 26.02.2004 by RST.
-// $Id: GameAIAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameAIAdapters.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
import jake2.Defines;
+import jake2.Globals;
import jake2.client.M;
import jake2.qcommon.Com;
import jake2.util.*;
@@ -253,11 +254,11 @@ public class GameAIAdapters
if (self.monsterinfo.idle_time != 0)
{
self.monsterinfo.search.think(self);
- self.monsterinfo.idle_time = GameBase.level.time + 15 + Lib.random() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15;
}
else
{
- self.monsterinfo.idle_time = GameBase.level.time + Lib.random() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15;
}
}
}
@@ -314,11 +315,11 @@ public class GameAIAdapters
if (self.monsterinfo.idle_time != 0)
{
self.monsterinfo.idle.think(self);
- self.monsterinfo.idle_time = GameBase.level.time + 15 + Lib.random() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15;
}
else
{
- self.monsterinfo.idle_time = GameBase.level.time + Lib.random() * 15;
+ self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15;
}
}
}
@@ -846,12 +847,14 @@ public class GameAIAdapters
trace_t tr;
float[] dest = { 0, 0, 0 };
- float v[];
+ //float v[];
- v = Lib.tv(-15, -15, -15);
- Math3D.VectorCopy(v, ent.mins);
- v = Lib.tv(15, 15, 15);
- Math3D.VectorCopy(v, ent.maxs);
+ //v = Lib.tv(-15, -15, -15);
+ //Math3D.VectorCopy(v, ent.mins);
+ ent.mins[0] = ent.mins[1] = ent.mins[2] = -15;
+ //v = Lib.tv(15, 15, 15);
+ //Math3D.VectorCopy(v, ent.maxs);
+ ent.maxs[0] = ent.maxs[1] = ent.maxs[2] = 15;
if (ent.model != null)
GameBase.gi.setmodel(ent, ent.model);
@@ -861,7 +864,7 @@ public class GameAIAdapters
ent.movetype = Defines.MOVETYPE_TOSS;
ent.touch = GameUtilAdapters.Touch_Item;
- v = Lib.tv(0, 0, -128);
+ float v[] = {0, 0, -128};
Math3D.VectorAdd(ent.s.origin, v, dest);
tr = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, dest, ent, Defines.MASK_SOLID);
@@ -918,7 +921,7 @@ public class GameAIAdapters
if (self.s.frame == 10)
{
self.think = GameUtilAdapters.G_FreeEdictA;
- self.nextthink = GameBase.level.time + 8 + Lib.random() * 10;
+ self.nextthink = GameBase.level.time + 8 + Globals.rnd.nextFloat() * 10;
}
return true;
}
diff --git a/src/jake2/game/GameMiscAdapters.java b/src/jake2/game/GameMiscAdapters.java
index c4322d3..56aba1a 100644
--- a/src/jake2/game/GameMiscAdapters.java
+++ b/src/jake2/game/GameMiscAdapters.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 26.02.2004 by RST.
-// $Id: GameMiscAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameMiscAdapters.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -817,7 +817,7 @@ public class GameMiscAdapters
if (e.count == 0)
continue;
n = e.count - 1;
- if (n > l)
+ if (n >= l)
{
e.s.frame = 12;
continue;
diff --git a/src/jake2/game/PlayerClient.java b/src/jake2/game/PlayerClient.java
index ba75cde..a7d06dd 100644
--- a/src/jake2/game/PlayerClient.java
+++ b/src/jake2/game/PlayerClient.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 28.12.2003 by RST.
-// $Id: PlayerClient.java,v 1.2 2004-07-08 15:58:43 hzi Exp $
+// $Id: PlayerClient.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -334,7 +334,7 @@ public class PlayerClient extends PlayerHud {
//memset(& client.resp, 0, sizeof(client.resp));
client.resp.clear(); // ok.
client.resp.enterframe = level.framenum;
- client.resp.coop_respawn = client.pers.getClone();
+ client.resp.coop_respawn.set(client.pers);
}
/*
diff --git a/src/jake2/game/client_persistant_t.java b/src/jake2/game/client_persistant_t.java
index 944767e..5014d3b 100644
--- a/src/jake2/game/client_persistant_t.java
+++ b/src/jake2/game/client_persistant_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: client_persistant_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: client_persistant_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -31,14 +31,14 @@ import java.nio.ByteBuffer;
public class client_persistant_t implements Cloneable {
- public client_persistant_t getClone() {
- try {
- return (client_persistant_t) this.clone();
- }
- catch (CloneNotSupportedException e) {
- return null;
- }
- }
+// public client_persistant_t getClone() {
+// try {
+// return (client_persistant_t) this.clone();
+// }
+// catch (CloneNotSupportedException e) {
+// return null;
+// }
+// }
public void set(client_persistant_t from)
{
@@ -50,7 +50,8 @@ public class client_persistant_t implements Cloneable {
max_health = from.max_health;
savedFlags = from.savedFlags;
selected_item = from.selected_item;
- inventory = Lib.clone(from.inventory);
+ System.arraycopy(from.inventory, 0, inventory, 0, inventory.length);
+ //inventory = Lib.clone(from.inventory);
max_bullets = from.max_bullets;
max_shells = from.max_shells;
max_rockets = from.max_rockets;
diff --git a/src/jake2/game/client_respawn_t.java b/src/jake2/game/client_respawn_t.java
index f24a15c..a2ed8d5 100644
--- a/src/jake2/game/client_respawn_t.java
+++ b/src/jake2/game/client_respawn_t.java
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: client_respawn_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: client_respawn_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -42,7 +42,7 @@ public class client_respawn_t
coop_respawn.set(from.coop_respawn);
enterframe = from.enterframe;
score = from.score;
- cmd_angles = Lib.clone(cmd_angles);
+ cmd_angles = Lib.clone(from.cmd_angles);
spectator = from.spectator;
}
diff --git a/src/jake2/game/cplane_t.java b/src/jake2/game/cplane_t.java
index 2eb29e9..4465a76 100644
--- a/src/jake2/game/cplane_t.java
+++ b/src/jake2/game/cplane_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: cplane_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: cplane_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -34,17 +34,18 @@ public class cplane_t
public byte signbits; // signx + (signy<<1) + (signz<<1)
public byte pad[] = { 0, 0 };
- public cplane_t getClone()
- {
- cplane_t out = new cplane_t();
- out.normal = Lib.clone(normal);
- out.dist = dist;
- out.type = type;
- out.signbits = signbits;
- out.pad = Lib.clone(pad);
-
- return out;
- }
+// public cplane_t getClone()
+// {
+// cplane_t out = new cplane_t();
+// Math3D.set(out.normal, normal);
+// out.dist = dist;
+// out.type = type;
+// out.signbits = signbits;
+// out.pad[0] = pad[0];
+// out.pad[1] = pad[1];
+//
+// return out;
+// }
public void set(cplane_t c)
{
diff --git a/src/jake2/game/player_state_t.java b/src/jake2/game/player_state_t.java
index f8d4860..3ecc17d 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.1 2004-07-07 19:59:26 hzi Exp $
+// $Id: player_state_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -95,7 +95,7 @@ public class player_state_t {
fov = from.fov;
rdflags = from.rdflags;
- stats = new short[Defines.MAX_STATS];
+ //stats = new short[Defines.MAX_STATS];
System.arraycopy(from.stats, 0, stats,0, Defines.MAX_STATS);
return this;
diff --git a/src/jake2/game/trace_t.java b/src/jake2/game/trace_t.java
index efb65fb..ac6d413 100644
--- a/src/jake2/game/trace_t.java
+++ b/src/jake2/game/trace_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: trace_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: trace_t.java,v 1.3 2004-07-08 20:24:29 hzi Exp $
package jake2.game;
@@ -44,23 +44,23 @@ public class trace_t implements Cloneable {
allsolid = from.allsolid;
startsolid = from.allsolid;
fraction = from.fraction;
- endpos = Lib.clone(endpos);
- plane = from.plane.getClone();
+ endpos = Lib.clone(from.endpos);
+ plane.set(from.plane);
surface = from.surface;
contents = from.contents;
ent = from.ent;
}
// =============
- public trace_t getClone() {
- trace_t out = null;
- try {
- out = (trace_t) this.clone();
- out.plane = plane.getClone();
- endpos = Lib.clone(endpos);
- }
- catch (CloneNotSupportedException e) {
- }
- return out;
- }
+// public trace_t getClone() {
+// trace_t out = null;
+// try {
+// out = (trace_t) this.clone();
+// out.plane = plane.getClone();
+// out.endpos = Lib.clone(endpos);
+// }
+// catch (CloneNotSupportedException e) {
+// }
+// return out;
+// }
}
diff --git a/src/jake2/qcommon/MSG.java b/src/jake2/qcommon/MSG.java
index 3d18798..36b1467 100644
--- a/src/jake2/qcommon/MSG.java
+++ b/src/jake2/qcommon/MSG.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 29.11.2003 by RST.
-// $Id: MSG.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+// $Id: MSG.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
package jake2.qcommon;
@@ -34,9 +34,6 @@ public class MSG extends GameBase {
//ok.
public static void WriteChar(sizebuf_t sb, int c) {
-// if (c < -128 || c > 127)
-// Com.Error(ERR_FATAL, "WriteChar: range error");
-
sb.data[SZ.GetSpace(sb, 1)] = (byte) (c & 0xFF);
}
@@ -48,11 +45,6 @@ public class MSG extends GameBase {
//ok.
public static void WriteByte(sizebuf_t sb, int c) {
- byte buf;
-
- //if (c < 0 || c > 255)
- //Com.Error(ERR_FATAL, "WriteByte: range error");
-
sb.data[SZ.GetSpace(sb, 1)] = (byte) (c & 0xFF);
}
@@ -63,11 +55,6 @@ public class MSG extends GameBase {
public static void WriteShort(sizebuf_t sb, int c) {
-
- // TODO brauchen wir nicht (cwei)
- // if (c < -32768 || c > 32767)
- // Com.Error(ERR_FATAL, "WriteShort: range error");
-
int i = SZ.GetSpace(sb, 2);
sb.data[i++] = (byte) (c & 0xff);
sb.data[i] = (byte) ((c >>> 8) & 0xFF);
@@ -75,7 +62,6 @@ public class MSG extends GameBase {
//ok.
public static void WriteInt(sizebuf_t sb, int c) {
-
int i = SZ.GetSpace(sb, 4);
sb.data[i++] = (byte) ((c & 0xff));
sb.data[i++] = (byte) ((c >>> 8) & 0xff);
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index bf7771c..3da48ca 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.2 2004-07-08 15:58:46 hzi Exp $
+ * $Id: Qcommon.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -110,13 +110,13 @@ public final class Qcommon extends Globals {
NET.NET_Init();
Netchan.Netchan_Init();
- //SV_MAIN.SV_Init();
+ SV_MAIN.SV_Init();
CL.Init();
// add + commands from command line
if (!Cbuf.AddLateCommands()) {
// if the user didn't give any commands, run default action
- Cbuf.AddText("d1\n");
+ //Cbuf.AddText("d1\n");
Cbuf.Execute();
} else {
// the user asked for something explicit
@@ -183,7 +183,6 @@ public final class Qcommon extends Globals {
Globals.logfile_active= Cvar.Get("logfile", "0", 0);
Globals.showtrace= Cvar.Get("showtrace", "0", 0);
Globals.dedicated= Cvar.Get("dedicated", "0", CVAR_NOSET);
- Globals.slomo= Cvar.Get("slomo", "1", 0);
String s = Com.sprintf("%4.2f %s %s %s",
new Vargs(4)
.add(Globals.VERSION)
diff --git a/src/jake2/qcommon/qfiles.java b/src/jake2/qcommon/qfiles.java
index bda2233..ae7fdf6 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.2 2004-07-08 15:58:46 hzi Exp $
+ * $Id: qfiles.java,v 1.3 2004-07-08 20:24:48 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -114,6 +114,52 @@ public class qfiles {
/*
========================================================================
+ TGA files are used for sky planes
+
+ ========================================================================
+ */
+ public static class tga_t {
+
+ // targa header
+ public int id_length, colormap_type, image_type; // unsigned char
+ public int colormap_index, colormap_length; // unsigned short
+ public int colormap_size; // unsigned char
+ public int x_origin, y_origin, width, height; // unsigned short
+ public int pixel_size, attributes; // unsigned char
+
+ public ByteBuffer data; // (un)compressed data
+
+ public tga_t(byte[] dataBytes) {
+ this(ByteBuffer.wrap(dataBytes));
+ }
+
+ public tga_t(ByteBuffer b) {
+ // is stored as little endian
+ b.order(ByteOrder.LITTLE_ENDIAN);
+
+ // fill header
+ id_length = b.get() & 0xFF;
+ colormap_type = b.get() & 0xFF;
+ image_type = b.get() & 0xFF;
+ colormap_index = b.getShort() & 0xFFFF;
+ colormap_length = b.getShort() & 0xFFFF;
+ colormap_size = b.get() & 0xFF;
+ x_origin = b.getShort() & 0xFFFF;
+ y_origin = b.getShort() & 0xFFFF;
+ width = b.getShort() & 0xFFFF;
+ height = b.getShort() & 0xFFFF;
+ pixel_size = b.get() & 0xFF;
+ attributes = b.get() & 0xFF;
+
+ // fill data
+ data = b.slice();
+ }
+
+ }
+
+ /*
+ ========================================================================
+
.MD2 triangle model file format
========================================================================
diff --git a/src/jake2/render/jogl/Image.java b/src/jake2/render/jogl/Image.java
index 0f29750..4e65481 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.1 2004-07-07 19:59:38 hzi Exp $
+ * $Id: Image.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -549,204 +549,179 @@ public abstract class Image extends Main {
//
// =========================================================
// */
- //
- // typedef struct _TargaHeader {
- // unsigned char id_length, colormap_type, image_type;
- // unsigned short colormap_index, colormap_length;
- // unsigned char colormap_size;
- // unsigned short x_origin, y_origin, width, height;
- // unsigned char pixel_size, attributes;
- // } TargaHeader;
- //
- //
/*
=============
LoadTGA
=============
*/
byte[] LoadTGA(String name, Dimension dim) {
- // TODO LoadTGA()
- // int columns, rows, numPixels;
- // byte *pixbuf;
- // int row, column;
- // byte *buf_p;
- // byte *buffer;
- // int length;
- // TargaHeader targa_header;
- // byte *targa_rgba;
- // byte tmp[2];
- //
- // *pic = NULL;
- //
- // //
- // // load the file
- // //
- // length = ri.FS_LoadFile (name, (void **)&buffer);
- // if (!buffer)
- // {
- // ri.Con_Printf (PRINT_DEVELOPER, "Bad tga file %s\n", name);
- // return;
- // }
- //
- // buf_p = buffer;
- //
- // targa_header.id_length = *buf_p++;
- // targa_header.colormap_type = *buf_p++;
- // targa_header.image_type = *buf_p++;
- //
- // tmp[0] = buf_p[0];
- // tmp[1] = buf_p[1];
- // targa_header.colormap_index = LittleShort ( *((short *)tmp) );
- // buf_p+=2;
- // tmp[0] = buf_p[0];
- // tmp[1] = buf_p[1];
- // targa_header.colormap_length = LittleShort ( *((short *)tmp) );
- // buf_p+=2;
- // targa_header.colormap_size = *buf_p++;
- // targa_header.x_origin = LittleShort ( *((short *)buf_p) );
- // buf_p+=2;
- // targa_header.y_origin = LittleShort ( *((short *)buf_p) );
- // buf_p+=2;
- // targa_header.width = LittleShort ( *((short *)buf_p) );
- // buf_p+=2;
- // targa_header.height = LittleShort ( *((short *)buf_p) );
- // buf_p+=2;
- // targa_header.pixel_size = *buf_p++;
- // targa_header.attributes = *buf_p++;
- //
- // if (targa_header.image_type!=2
- // && targa_header.image_type!=10)
- // ri.Sys_Error (ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
- //
- // if (targa_header.colormap_type !=0
- // || (targa_header.pixel_size!=32 && targa_header.pixel_size!=24))
- // ri.Sys_Error (ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
- //
- // columns = targa_header.width;
- // rows = targa_header.height;
- // numPixels = columns * rows;
- //
- // if (width)
- // *width = columns;
- // if (height)
- // *height = rows;
- //
- // targa_rgba = malloc (numPixels*4);
- // *pic = targa_rgba;
+ int columns, rows, numPixels;
+ int pixbuf; // index into pic
+ int row, column;
+ byte[] raw;
+ ByteBuffer buf_p;
+ int length;
+ qfiles.tga_t targa_header;
+ byte[] pic = null;
+
//
- // if (targa_header.id_length != 0)
- // buf_p += targa_header.id_length; // skip TARGA image comment
- //
- // if (targa_header.image_type==2) { // Uncompressed, RGB images
- // for(row=rows-1; row>=0; row--) {
- // pixbuf = targa_rgba + row*columns*4;
- // for(column=0; column<columns; column++) {
- // unsigned char red,green,blue,alphabyte;
- // switch (targa_header.pixel_size) {
- // case 24:
- //
- // blue = *buf_p++;
- // green = *buf_p++;
- // red = *buf_p++;
- // *pixbuf++ = red;
- // *pixbuf++ = green;
- // *pixbuf++ = blue;
- // *pixbuf++ = 255;
- // break;
- // case 32:
- // blue = *buf_p++;
- // green = *buf_p++;
- // red = *buf_p++;
- // alphabyte = *buf_p++;
- // *pixbuf++ = red;
- // *pixbuf++ = green;
- // *pixbuf++ = blue;
- // *pixbuf++ = alphabyte;
- // break;
- // }
- // }
- // }
- // }
- // else if (targa_header.image_type==10) { // Runlength encoded RGB images
- // unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j;
- // for(row=rows-1; row>=0; row--) {
- // pixbuf = targa_rgba + row*columns*4;
- // for(column=0; column<columns; ) {
- // packetHeader= *buf_p++;
- // packetSize = 1 + (packetHeader & 0x7f);
- // if (packetHeader & 0x80) { // run-length packet
- // switch (targa_header.pixel_size) {
- // case 24:
- // blue = *buf_p++;
- // green = *buf_p++;
- // red = *buf_p++;
- // alphabyte = 255;
- // break;
- // case 32:
- // blue = *buf_p++;
- // green = *buf_p++;
- // red = *buf_p++;
- // alphabyte = *buf_p++;
- // break;
- // }
- //
- // for(j=0;j<packetSize;j++) {
- // *pixbuf++=red;
- // *pixbuf++=green;
- // *pixbuf++=blue;
- // *pixbuf++=alphabyte;
- // column++;
- // if (column==columns) { // run spans across rows
- // column=0;
- // if (row>0)
- // row--;
- // else
- // goto breakOut;
- // pixbuf = targa_rgba + row*columns*4;
- // }
- // }
- // }
- // else { // non run-length packet
- // for(j=0;j<packetSize;j++) {
- // switch (targa_header.pixel_size) {
- // case 24:
- // blue = *buf_p++;
- // green = *buf_p++;
- // red = *buf_p++;
- // *pixbuf++ = red;
- // *pixbuf++ = green;
- // *pixbuf++ = blue;
- // *pixbuf++ = 255;
- // break;
- // case 32:
- // blue = *buf_p++;
- // green = *buf_p++;
- // red = *buf_p++;
- // alphabyte = *buf_p++;
- // *pixbuf++ = red;
- // *pixbuf++ = green;
- // *pixbuf++ = blue;
- // *pixbuf++ = alphabyte;
- // break;
- // }
- // column++;
- // if (column==columns) { // pixel packet run spans across rows
- // column=0;
- // if (row>0)
- // row--;
- // else
- // goto breakOut;
- // pixbuf = targa_rgba + row*columns*4;
- // }
- // }
- // }
- // }
- // breakOut:;
- // }
- // }
+ // load the file
//
- // ri.FS_FreeFile (buffer);
- return null; // remove this
+ raw = ri.FS_LoadFile (name);
+
+ if (raw == null)
+ {
+ ri.Con_Printf(Defines.PRINT_DEVELOPER, "Bad tga file "+ name +'\n');
+ return null;
+ }
+
+ targa_header = new qfiles.tga_t(raw);
+
+ if (targa_header.image_type != 2 && targa_header.image_type != 10)
+ ri.Sys_Error(Defines.ERR_DROP, "LoadTGA: Only type 2 and 10 targa RGB images supported\n");
+
+ if (targa_header.colormap_type != 0 || (targa_header.pixel_size != 32 && targa_header.pixel_size != 24))
+ ri.Sys_Error (Defines.ERR_DROP, "LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n");
+
+ columns = targa_header.width;
+ rows = targa_header.height;
+ numPixels = columns * rows;
+
+ if (dim != null) {
+ dim.width = columns;
+ dim.height = rows;
+ }
+
+ pic = new byte[numPixels * 4]; // targa_rgba;
+
+ if (targa_header.id_length != 0)
+ targa_header.data.position(targa_header.id_length); // skip TARGA image comment
+
+ buf_p = targa_header.data;
+
+ byte red,green,blue,alphabyte;
+ red = green = blue = alphabyte = 0;
+ int packetHeader, packetSize, j;
+
+ if (targa_header.image_type==2) { // Uncompressed, RGB images
+ for(row=rows-1; row>=0; row--) {
+
+ pixbuf = row * columns * 4;
+
+ for(column=0; column<columns; column++) {
+ switch (targa_header.pixel_size) {
+ case 24:
+
+ blue = buf_p.get();
+ green = buf_p.get();
+ red = buf_p.get();
+ pic[pixbuf++] = red;
+ pic[pixbuf++] = green;
+ pic[pixbuf++] = blue;
+ pic[pixbuf++] = (byte)255;
+ break;
+ case 32:
+ blue = buf_p.get();
+ green = buf_p.get();
+ red = buf_p.get();
+ alphabyte = buf_p.get();
+ pic[pixbuf++] = red;
+ pic[pixbuf++] = green;
+ pic[pixbuf++] = blue;
+ pic[pixbuf++] = alphabyte;
+ break;
+ }
+ }
+ }
+ }
+ else if (targa_header.image_type==10) { // Runlength encoded RGB images
+ for(row=rows-1; row>=0; row--) {
+
+ pixbuf = row * columns * 4;
+ try {
+
+ for(column=0; column<columns; ) {
+
+ packetHeader= buf_p.get() & 0xFF;
+ packetSize = 1 + (packetHeader & 0x7f);
+
+ if ((packetHeader & 0x80) != 0) { // run-length packet
+ switch (targa_header.pixel_size) {
+ case 24:
+ blue = buf_p.get();
+ green = buf_p.get();
+ red = buf_p.get();
+ alphabyte = (byte)255;
+ break;
+ case 32:
+ blue = buf_p.get();
+ green = buf_p.get();
+ red = buf_p.get();
+ alphabyte = buf_p.get();
+ break;
+ }
+
+ for(j=0;j<packetSize;j++) {
+ pic[pixbuf++]=red;
+ pic[pixbuf++]=green;
+ pic[pixbuf++]=blue;
+ pic[pixbuf++]=alphabyte;
+ column++;
+ if (column==columns) { // run spans across rows
+ column=0;
+ if (row>0)
+ row--;
+ else
+ // goto label breakOut;
+ throw new longjmpException();
+
+ pixbuf = row * columns * 4;
+ }
+ }
+ }
+ else { // non run-length packet
+ for(j=0;j<packetSize;j++) {
+ switch (targa_header.pixel_size) {
+ case 24:
+ blue = buf_p.get();
+ green = buf_p.get();
+ red = buf_p.get();
+ pic[pixbuf++] = red;
+ pic[pixbuf++] = green;
+ pic[pixbuf++] = blue;
+ pic[pixbuf++] = (byte)255;
+ break;
+ case 32:
+ blue = buf_p.get();
+ green = buf_p.get();
+ red = buf_p.get();
+ alphabyte = buf_p.get();
+ pic[pixbuf++] = red;
+ pic[pixbuf++] = green;
+ pic[pixbuf++] = blue;
+ pic[pixbuf++] = alphabyte;
+ break;
+ }
+ column++;
+ if (column==columns) { // pixel packet run spans across rows
+ column=0;
+ if (row>0)
+ row--;
+ else
+ // goto label breakOut;
+ throw new longjmpException();
+
+ pixbuf = row * columns * 4;
+ }
+ }
+ }
+ }
+ } catch (longjmpException e){
+ // label breakOut:
+ }
+ }
+ }
+ return pic;
}
/*
diff --git a/src/jake2/render/jogl/Impl.java b/src/jake2/render/jogl/Impl.java
index 48241db..ba8b929 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.2 2004-07-08 15:58:45 hzi Exp $
+ * $Id: Impl.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -137,11 +137,12 @@ public class Impl extends Misc implements GLEventListener {
canvas.addMouseListener(KBD.listener);
canvas.addMouseMotionListener(KBD.listener);
window.addComponentListener(KBD.listener);
-
+ canvas.requestFocus();
+
window.pack();
window.show();
canvas.requestFocus();
-
+
this.canvas = canvas;
vid.width = newDim.width;
@@ -222,12 +223,10 @@ public class Impl extends Misc implements GLEventListener {
this.contextInUse = true;
if (switchToCallback) {
- if (callback == null)
- ri.updateScreenCallback();
- else
- callback.execute();
+ callback.execute();
}
- else {
+ else
+ {
// after the first run (initialization) switch to callback
switchToCallback = true;
@@ -271,9 +270,9 @@ public class Impl extends Misc implements GLEventListener {
* @see jake2.client.refexport_t#updateScreen()
*/
public void updateScreen(xcommand_t callback) {
- if (canvas == null) {
- throw new IllegalStateException("Refresh modul \"" + DRIVER_NAME + "\" have to be initialized.");
- }
+// 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 fc23e4a..214641d 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.1 2004-07-07 19:59:38 hzi Exp $
+ * $Id: Light.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -29,6 +29,8 @@ 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;
@@ -64,30 +66,30 @@ public abstract class Light extends Warp {
void R_RenderDlight (dlight_t light)
{
-// int i, j;
-// float a;
-// vec3_t v;
-// float rad;
-//
-// rad = light.intensity * 0.35;
-//
-// VectorSubtract (light.origin, r_origin, v);
-//
-// qglBegin (GL_TRIANGLE_FAN);
-// qglColor3f (light.color[0]*0.2, light.color[1]*0.2, light.color[2]*0.2);
-// for (i=0 ; i<3 ; i++)
-// v[i] = light.origin[i] - vpn[i]*rad;
-// qglVertex3fv (v);
-// qglColor3f (0,0,0);
-// for (i=16 ; i>=0 ; i--)
-// {
-// a = i/16.0 * M_PI*2;
-// for (j=0 ; j<3 ; j++)
-// v[j] = light.origin[j] + vright[j]*cos(a)*rad
-// + vup[j]*sin(a)*rad;
-// qglVertex3fv (v);
-// }
-// qglEnd ();
+ int i, j;
+ float a;
+ float[] v = {0, 0, 0};
+ float rad;
+
+ rad = light.intensity * 0.35f;
+
+ Math3D.VectorSubtract (light.origin, r_origin, v);
+
+ gl.glBegin (GL.GL_TRIANGLE_FAN);
+ 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.glColor3f (0,0,0);
+ for (i=16 ; i>=0 ; i--)
+ {
+ a = (float)(i/16.0f * Math.PI*2);
+ 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.glEnd ();
}
/*
@@ -97,29 +99,31 @@ public abstract class Light extends Warp {
*/
void R_RenderDlights()
{
-// int i;
-// dlight_t *l;
-//
-// if (!gl_flashblend.value)
-// return;
-//
-// r_dlightframecount = r_framecount + 1; // because the count hasn't
-// // advanced yet for this frame
-// qglDepthMask (0);
-// qglDisable (GL_TEXTURE_2D);
-// qglShadeModel (GL_SMOOTH);
-// qglEnable (GL_BLEND);
-// qglBlendFunc (GL_ONE, GL_ONE);
-//
-// l = r_newrefdef.dlights;
-// for (i=0 ; i<r_newrefdef.num_dlights ; i++, l++)
-// R_RenderDlight (l);
-//
-// qglColor3f (1,1,1);
-// qglDisable (GL_BLEND);
-// qglEnable (GL_TEXTURE_2D);
-// qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-// qglDepthMask (1);
+ int i;
+ dlight_t l;
+
+ if (gl_flashblend.value == 0)
+ return;
+
+ r_dlightframecount = r_framecount + 1; // because the count hasn't
+ // advanced yet for this frame
+ gl.glDepthMask(false);
+ gl.glDisable(GL.GL_TEXTURE_2D);
+ gl.glShadeModel (GL.GL_SMOOTH);
+ gl.glEnable (GL.GL_BLEND);
+ gl.glBlendFunc (GL.GL_ONE, GL.GL_ONE);
+
+ for (i=0 ; i<r_newrefdef.num_dlights ; i++)
+ {
+ l = r_newrefdef.dlights[i];
+ R_RenderDlight (l);
+ }
+
+ gl.glColor3f (1,1,1);
+ gl.glDisable(GL.GL_BLEND);
+ gl.glEnable(GL.GL_TEXTURE_2D);
+ gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
+ gl.glDepthMask(true);
}
@@ -390,76 +394,78 @@ public abstract class Light extends Warp {
*/
void R_AddDynamicLights(msurface_t surf)
{
-// int lnum;
-// int sd, td;
-// float fdist, frad, fminlight;
-// vec3_t impact, local;
-// int s, t;
-// int i;
-// int smax, tmax;
-// mtexinfo_t *tex;
-// dlight_t *dl;
-// float *pfBL;
-// float fsacc, ftacc;
-//
-// smax = (surf.extents[0]>>4)+1;
-// tmax = (surf.extents[1]>>4)+1;
-// tex = surf.texinfo;
-//
-// for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
-// {
-// if ( !(surf.dlightbits & (1<<lnum) ) )
-// continue; // not lit by this light
-//
-// dl = &r_newrefdef.dlights[lnum];
-// frad = dl.intensity;
-// fdist = DotProduct (dl.origin, surf.plane.normal) -
-// surf.plane.dist;
-// frad -= fabs(fdist);
-// // rad is now the highest intensity on the plane
-//
-// fminlight = DLIGHT_CUTOFF; // FIXME: make configurable?
-// if (frad < fminlight)
-// continue;
-// fminlight = frad - fminlight;
-//
-// for (i=0 ; i<3 ; i++)
-// {
-// impact[i] = dl.origin[i] -
-// surf.plane.normal[i]*fdist;
-// }
-//
-// local[0] = DotProduct (impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0];
-// local[1] = DotProduct (impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1];
-//
-// pfBL = s_blocklights;
-// for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16)
-// {
-// td = local[1] - ftacc;
-// if ( td < 0 )
-// td = -td;
-//
-// for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBL += 3)
-// {
-// sd = Q_ftol( local[0] - fsacc );
-//
-// if ( sd < 0 )
-// sd = -sd;
-//
-// if (sd > td)
-// fdist = sd + (td>>1);
-// else
-// fdist = td + (sd>>1);
-//
-// if ( fdist < fminlight )
-// {
-// pfBL[0] += ( frad - fdist ) * dl.color[0];
-// pfBL[1] += ( frad - fdist ) * dl.color[1];
-// pfBL[2] += ( frad - fdist ) * dl.color[2];
-// }
-// }
-// }
-// }
+ int lnum;
+ int sd, td;
+ float fdist, frad, fminlight;
+ float[] impact = {0, 0, 0};
+ float[] local = {0, 0, 0};
+ int s, t;
+ int i;
+ int smax, tmax;
+ mtexinfo_t tex;
+ dlight_t dl;
+ float[] pfBL;
+ float fsacc, ftacc;
+
+ smax = (surf.extents[0]>>4)+1;
+ tmax = (surf.extents[1]>>4)+1;
+ tex = surf.texinfo;
+
+ for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++)
+ {
+ if ( (surf.dlightbits & (1<<lnum)) == 0 )
+ continue; // not lit by this light
+
+ dl = r_newrefdef.dlights[lnum];
+ frad = dl.intensity;
+ fdist = Math3D.DotProduct (dl.origin, surf.plane.normal) -
+ surf.plane.dist;
+ frad -= Math.abs(fdist);
+ // rad is now the highest intensity on the plane
+
+ fminlight = DLIGHT_CUTOFF; // FIXME: make configurable?
+ if (frad < fminlight)
+ continue;
+ fminlight = frad - fminlight;
+
+ for (i=0 ; i<3 ; i++)
+ {
+ impact[i] = dl.origin[i] -
+ surf.plane.normal[i]*fdist;
+ }
+
+ local[0] = Math3D.DotProduct (impact, tex.vecs[0]) + tex.vecs[0][3] - surf.texturemins[0];
+ local[1] = Math3D.DotProduct (impact, tex.vecs[1]) + tex.vecs[1][3] - surf.texturemins[1];
+
+ pfBL = s_blocklights;
+ int pfBLindex = 0;
+ for (t = 0, ftacc = 0 ; t<tmax ; t++, ftacc += 16)
+ {
+ td = (int)(local[1] - ftacc);
+ if ( td < 0 )
+ td = -td;
+
+ for ( s=0, fsacc = 0 ; s<smax ; s++, fsacc += 16, pfBLindex += 3)
+ {
+ sd = (int)( local[0] - fsacc );
+
+ if ( sd < 0 )
+ sd = -sd;
+
+ if (sd > td)
+ fdist = sd + (td>>1);
+ else
+ fdist = td + (sd>>1);
+
+ if ( fdist < fminlight )
+ {
+ pfBL[pfBLindex + 0] += ( frad - fdist ) * dl.color[0];
+ pfBL[pfBLindex + 1] += ( frad - fdist ) * dl.color[1];
+ pfBL[pfBLindex + 2] += ( frad - fdist ) * dl.color[2];
+ }
+ }
+ }
+ }
}
diff --git a/src/jake2/render/jogl/Mesh.java b/src/jake2/render/jogl/Mesh.java
index 45d28bb..37e4445 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.2 2004-07-08 15:58:45 hzi Exp $
+ * $Id: Mesh.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -228,7 +228,7 @@ public abstract class Mesh extends Light {
else
{
gl.glEnableClientState( GL.GL_COLOR_ARRAY );
- gl.glColorPointer( 3, GL.GL_FLOAT, 0, colorArrayBuf );
+ gl.glColorPointer( 4, GL.GL_FLOAT, 0, colorArrayBuf );
//
// pre light everything
@@ -237,7 +237,7 @@ public abstract class Mesh extends Light {
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]);
+ colorArrayBuf.put(l * shadelight[0]).put(l * shadelight[1]).put(l * shadelight[2]).put(alpha);
}
}
diff --git a/src/jake2/render/jogl/Surf.java b/src/jake2/render/jogl/Surf.java
index 7baf69f..7f05332 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.1 2004-07-07 19:59:43 hzi Exp $
+ * $Id: Surf.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -36,6 +36,8 @@ 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;
@@ -86,15 +88,21 @@ public abstract class Surf extends Draw {
int current_lightmap_texture;
msurface_t[] lightmap_surfaces = new msurface_t[MAX_LIGHTMAPS];
-
int[] allocated = new int[BLOCK_WIDTH];
// 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];
+
+ public gllightmapstate_t() {
+ for (int i = 0; i < MAX_LIGHTMAPS; i++)
+ lightmap_surfaces[i] = new msurface_t();
+ }
+
public void clearLightmapSurfaces() {
for (int i = 0; i < MAX_LIGHTMAPS; i++)
+ // TODO lightmap_surfaces[i].clear();
lightmap_surfaces[i] = new msurface_t();
}
@@ -390,64 +398,74 @@ public abstract class Surf extends Draw {
for ( surf = gl_lms.lightmap_surfaces[0]; surf != null; surf = surf.lightmapchain )
{
-// int smax, tmax;
-// byte *base;
-//
-// smax = (surf->extents[0]>>4)+1;
-// tmax = (surf->extents[1]>>4)+1;
-//
-// if ( LM_AllocBlock( smax, tmax, &surf->dlight_s, &surf->dlight_t ) )
-// {
-// base = gl_lms.lightmap_buffer;
-// base += ( surf->dlight_t * BLOCK_WIDTH + surf->dlight_s ) * LIGHTMAP_BYTES;
-//
-// R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
-// }
-// else
-// {
-// msurface_t *drawsurf;
-//
-// // upload what we have so far
-// LM_UploadBlock( true );
-//
-// // draw all surfaces that use this lightmap
-// for ( drawsurf = newdrawsurf; drawsurf != surf; drawsurf = drawsurf->lightmapchain )
-// {
-// if ( drawsurf->polys )
-// DrawGLPolyChain( drawsurf->polys,
-// ( drawsurf->light_s - drawsurf->dlight_s ) * ( 1.0 / 128.0 ),
-// ( drawsurf->light_t - drawsurf->dlight_t ) * ( 1.0 / 128.0 ) );
-// }
-//
-// newdrawsurf = drawsurf;
-//
-// // clear the block
-// LM_InitBlock();
-//
-// // try uploading the block now
-// if ( !LM_AllocBlock( smax, tmax, &surf->dlight_s, &surf->dlight_t ) )
-// {
-// ri.Sys_Error( ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed (dynamic)\n", smax, tmax );
-// }
-//
-// base = gl_lms.lightmap_buffer;
-// base += ( surf->dlight_t * BLOCK_WIDTH + surf->dlight_s ) * LIGHTMAP_BYTES;
-//
-// R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
-// }
+ int smax, tmax;
+ ByteBuffer base;
+
+ smax = (surf.extents[0]>>4)+1;
+ tmax = (surf.extents[1]>>4)+1;
+
+ pos_t lightPos = new pos_t(surf.dlight_s, surf.dlight_t);
+
+ if ( LM_AllocBlock( smax, tmax, lightPos) )
+ {
+ // kopiere die koordinaten zurueck
+ 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);
+
+ R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
+ }
+ else
+ {
+ msurface_t drawsurf;
+
+ // upload what we have so far
+ LM_UploadBlock( true );
+
+ // draw all surfaces that use this lightmap
+ for ( drawsurf = newdrawsurf; drawsurf != surf; drawsurf = drawsurf.lightmapchain )
+ {
+ if ( drawsurf.polys != null )
+ DrawGLPolyChain( drawsurf.polys,
+ ( drawsurf.light_s - drawsurf.dlight_s ) * ( 1.0f / 128.0f ),
+ ( drawsurf.light_t - drawsurf.dlight_t ) * ( 1.0f / 128.0f ) );
+ }
+
+ newdrawsurf = drawsurf;
+
+ // clear the block
+ LM_InitBlock();
+
+ // try uploading the block now
+ if ( !LM_AllocBlock( smax, tmax, lightPos) )
+ {
+ ri.Sys_Error( Defines.ERR_FATAL, "Consecutive calls to LM_AllocBlock(" + smax + "," + tmax + ") failed (dynamic)\n");
+ }
+
+ // kopiere die koordinaten zurueck
+ 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);
+
+ R_BuildLightMap (surf, base, BLOCK_WIDTH*LIGHTMAP_BYTES);
+ }
}
/*
** draw remainder of dynamic lightmaps that haven't been uploaded yet
*/
-// if ( newdrawsurf != null )
-// LM_UploadBlock( true );
-//
-// for ( surf = newdrawsurf; surf != null; surf = surf.lightmapchain )
-// {
-// if ( surf.polys != null )
-// DrawGLPolyChain( surf.polys, ( surf.light_s - surf.dlight_s ) * ( 1.0f / 128.0f ), ( surf.light_t - surf.dlight_t ) * ( 1.0f / 128.0f ) );
-// }
+ if ( newdrawsurf != null )
+ LM_UploadBlock( true );
+
+ for ( surf = newdrawsurf; surf != null; surf = surf.lightmapchain )
+ {
+ if ( surf.polys != null )
+ DrawGLPolyChain( surf.polys, ( surf.light_s - surf.dlight_s ) * ( 1.0f / 128.0f ), ( surf.light_t - surf.dlight_t ) * ( 1.0f / 128.0f ) );
+ }
}
/*
@@ -457,6 +475,8 @@ public abstract class Surf extends Draw {
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glDepthMask( true );
}
+
+ private ByteBuffer temp2 = BufferUtils.newByteBuffer(34 * 34 * 4);
/*
================
@@ -503,57 +523,64 @@ public abstract class Surf extends Draw {
// PGM
// ======
-// /*
-// ** check for lightmap modification
-// */
-// for ( maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++ )
-// {
-// if ( r_newrefdef.lightstyles[fa->styles[maps]].white != fa->cached_light[maps] )
-// goto dynamic;
-// }
-//
-// // dynamic this frame or dynamic previously
-// if ( ( fa->dlightframe == r_framecount ) )
-// {
-// dynamic:
-// if ( gl_dynamic->value )
-// {
-// if (!( fa->texinfo->flags & (SURF_SKY|SURF_TRANS33|SURF_TRANS66|SURF_WARP ) ) )
-// {
-// is_dynamic = true;
-// }
-// }
-// }
-//
+ // ersetzt goto
+ boolean gotoDynamic = false;
+ /*
+ ** check for lightmap modification
+ */
+ for ( maps = 0; maps < Defines.MAXLIGHTMAPS && fa.styles[maps] != (byte)255; maps++ )
+ {
+ if ( r_newrefdef.lightstyles[fa.styles[maps] & 0xFF].white != fa.cached_light[maps] ) {
+ gotoDynamic = true;
+ break;
+ }
+ }
+
+ // this is a hack from cwei
+ if (maps == 4) maps--;
+
+ // dynamic this frame or dynamic previously
+ if ( gotoDynamic || ( fa.dlightframe == r_framecount ) )
+ {
+ // label dynamic:
+ if ( gl_dynamic.value != 0 )
+ {
+ if (( fa.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP ) ) == 0)
+ {
+ is_dynamic = true;
+ }
+ }
+ }
+
if ( is_dynamic )
{
-// if ( ( fa->styles[maps] >= 32 || fa->styles[maps] == 0 ) && ( fa->dlightframe != r_framecount ) )
-// {
-// unsigned temp[34*34];
-// int smax, tmax;
-//
-// smax = (fa->extents[0]>>4)+1;
-// tmax = (fa->extents[1]>>4)+1;
-//
-// R_BuildLightMap( fa, (void *)temp, smax*4 );
-// R_SetCacheState( fa );
-//
-// GL_Bind( gl_state.lightmap_textures + fa->lightmaptexturenum );
-//
-// qglTexSubImage2D( GL_TEXTURE_2D, 0,
-// fa->light_s, fa->light_t,
-// smax, tmax,
-// GL_LIGHTMAP_FORMAT,
-// GL_UNSIGNED_BYTE, temp );
-//
-// fa->lightmapchain = gl_lms.lightmap_surfaces[fa->lightmaptexturenum];
-// gl_lms.lightmap_surfaces[fa->lightmaptexturenum] = fa;
-// }
-// else
-// {
-// fa->lightmapchain = gl_lms.lightmap_surfaces[0];
-// gl_lms.lightmap_surfaces[0] = fa;
-// }
+ if ( ( (fa.styles[maps] & 0xFF) >= 32 || fa.styles[maps] == 0 ) && ( fa.dlightframe != r_framecount ) )
+ {
+ // ist ersetzt durch temp2: unsigned temp[34*34];
+ int smax, tmax;
+
+ smax = (fa.extents[0]>>4)+1;
+ tmax = (fa.extents[1]>>4)+1;
+
+ R_BuildLightMap( fa, temp2, smax*4 );
+ R_SetCacheState( fa );
+
+ GL_Bind( gl_state.lightmap_textures + fa.lightmaptexturenum );
+
+ gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
+ fa.light_s, fa.light_t,
+ smax, tmax,
+ GL_LIGHTMAP_FORMAT,
+ GL.GL_UNSIGNED_BYTE, temp2 );
+
+ fa.lightmapchain = gl_lms.lightmap_surfaces[fa.lightmaptexturenum];
+ gl_lms.lightmap_surfaces[fa.lightmaptexturenum] = fa;
+ }
+ else
+ {
+ fa.lightmapchain = gl_lms.lightmap_surfaces[0];
+ gl_lms.lightmap_surfaces[0] = fa;
+ }
}
else
{
@@ -689,6 +716,8 @@ public abstract class Surf extends Draw {
GL_TexEnv( GL.GL_REPLACE );
}
+ // direct buffer
+ ByteBuffer temp = BufferUtils.newByteBuffer(128 * 128 * 4);
void GL_RenderLightmappedPoly( msurface_t surf )
{
@@ -700,66 +729,74 @@ public abstract class Surf extends Draw {
int lmtex = surf.lightmaptexturenum;
glpoly_t p;
-// for ( map = 0; map < Defines.MAXLIGHTMAPS && surf.styles[map] != (byte)255; map++ )
-// {
-// if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] )
-// goto dynamic;
-// }
-//
-// // dynamic this frame or dynamic previously
-// if ( ( surf.dlightframe == r_framecount ) )
-// {
-// dynamic:
-// if ( gl_dynamic.value )
-// {
-// if ( !(surf.texinfo.flags & (SURF_SKY|SURF_TRANS33|SURF_TRANS66|SURF_WARP ) ) )
-// {
-// is_dynamic = true;
-// }
-// }
-// }
-//
+ // ersetzt goto
+ boolean gotoDynamic = false;
+
+ for ( map = 0; map < Defines.MAXLIGHTMAPS && (surf.styles[map] != (byte)255); map++ )
+ {
+ if ( r_newrefdef.lightstyles[surf.styles[map] & 0xFF].white != surf.cached_light[map] ) {
+ gotoDynamic = true;
+ break;
+ }
+ }
+
+ // this is a hack from cwei
+ if (map == 4) map--;
+
+ // dynamic this frame or dynamic previously
+ if ( gotoDynamic || ( surf.dlightframe == r_framecount ) )
+ {
+ // label dynamic:
+ if ( gl_dynamic.value != 0 )
+ {
+ if ( (surf.texinfo.flags & (Defines.SURF_SKY | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_WARP )) == 0 )
+ {
+ is_dynamic = true;
+ }
+ }
+ }
+
if ( is_dynamic )
{
-// unsigned temp[128*128];
-// int smax, tmax;
-//
+ // ist raus gezogen worden int[] temp = new int[128*128];
+ int smax, tmax;
+
if ( ( (surf.styles[map] & 0xFF) >= 32 || surf.styles[map] == 0 ) && ( surf.dlightframe != r_framecount ) )
{
-// smax = (surf.extents[0]>>4)+1;
-// tmax = (surf.extents[1]>>4)+1;
-//
-// R_BuildLightMap( surf, (void *)temp, smax*4 );
-// R_SetCacheState( surf );
-//
-// GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum );
-//
-// lmtex = surf.lightmaptexturenum;
-//
-// gl.glTexSubImage2D( GL_TEXTURE_2D, 0,
-// surf.light_s, surf.light_t,
-// smax, tmax,
-// GL_LIGHTMAP_FORMAT,
-// GL_UNSIGNED_BYTE, temp );
-//
+ smax = (surf.extents[0]>>4)+1;
+ tmax = (surf.extents[1]>>4)+1;
+
+ R_BuildLightMap( surf, temp, smax*4 );
+ R_SetCacheState( surf );
+
+ GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + surf.lightmaptexturenum );
+
+ lmtex = surf.lightmaptexturenum;
+
+ gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
+ surf.light_s, surf.light_t,
+ smax, tmax,
+ GL_LIGHTMAP_FORMAT,
+ GL.GL_UNSIGNED_BYTE, temp );
+
}
else
{
-// smax = (surf.extents[0]>>4)+1;
-// tmax = (surf.extents[1]>>4)+1;
-//
-// R_BuildLightMap( surf, (void *)temp, smax*4 );
-//
-// GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 );
-//
-// lmtex = 0;
-//
-// gl.glTexSubImage2D( GL_TEXTURE_2D, 0,
-// surf.light_s, surf.light_t,
-// smax, tmax,
-// GL_LIGHTMAP_FORMAT,
-// GL_UNSIGNED_BYTE, temp );
-//
+ smax = (surf.extents[0]>>4)+1;
+ tmax = (surf.extents[1]>>4)+1;
+
+ R_BuildLightMap( surf, temp, smax*4 );
+
+ GL_MBind( GL_TEXTURE1, gl_state.lightmap_textures + 0 );
+
+ lmtex = 0;
+
+ gl.glTexSubImage2D( GL.GL_TEXTURE_2D, 0,
+ surf.light_s, surf.light_t,
+ smax, tmax,
+ GL_LIGHTMAP_FORMAT,
+ GL.GL_UNSIGNED_BYTE, temp );
+
}
c_brush_polys++;
diff --git a/src/jake2/render/jogl/Warp.java b/src/jake2/render/jogl/Warp.java
index f02acbb..8ccb93a 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.2 2004-07-08 15:58:45 hzi Exp $
+ * $Id: Warp.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -698,8 +698,7 @@ public abstract class Warp extends Model {
pathname = "env/" + skyname + suf[i] + ".pcx";
} else {
// Com_sprintf (pathname, sizeof(pathname), "env/%s%s.tga", skyname, suf[i]);
- // TODO impl: LoadTGA
- pathname = "env/" + skyname + suf[i] + ".pcx";
+ pathname = "env/" + skyname + suf[i] + ".tga";
}
sky_images[i] = GL_FindImage(pathname, it_sky);
diff --git a/src/jake2/render/msurface_t.java b/src/jake2/render/msurface_t.java
index a43ddbd..c6247d9 100644
--- a/src/jake2/render/msurface_t.java
+++ b/src/jake2/render/msurface_t.java
@@ -19,13 +19,14 @@ 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.1 2004-07-07 19:59:35 hzi Exp $
+// $Id: msurface_t.java,v 1.2 2004-07-08 20:24:29 hzi Exp $
package jake2.render;
import java.nio.ByteBuffer;
import jake2.game.*;
+import jake2.qcommon.texinfo_t;
import jake2.*;
public class msurface_t
@@ -50,7 +51,8 @@ public class msurface_t
public msurface_t texturechain;
public msurface_t lightmapchain;
- public mtexinfo_t texinfo;
+ // TODO check this
+ public mtexinfo_t texinfo = new mtexinfo_t();
// lighting info
public int dlightframe;
@@ -62,5 +64,40 @@ public class msurface_t
// values currently used in lightmap
//public byte samples[]; // [numstyles*surfsize]
public ByteBuffer samples; // [numstyles*surfsize]
-
+
+ public void clear() {
+ visframe = 0;
+ //plane = null;
+ flags = 0;
+
+ firstedge = 0;
+ numedges = 0;
+
+ texturemins[0] = texturemins[1] = 0;
+ extents[0] = extents[1] = 0;
+
+ light_s = light_t = 0;
+ dlight_s = dlight_t = 0;
+
+ //polys = null;
+ texturechain = null;
+ lightmapchain = null;
+
+ //texinfo = null;
+
+ dlightframe = 0;
+ dlightbits = 0;
+
+ lightmaptexturenum = 0;
+
+ for (int i = 0; i < styles.length; i++)
+ {
+ styles[i] = 0;
+ }
+ for (int i = 0; i < cached_light.length; i++)
+ {
+ cached_light[i] = 0;
+ }
+ //samples = null;
+ }
}
diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java
index c6d433b..8f920ec 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.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_GAME.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
package jake2.server;
@@ -262,6 +262,9 @@ public class SV_GAME extends SV_INIT {
cluster = CM.CM_LeafCluster(leafnum);
area2 = CM.CM_LeafArea(leafnum);
+ // quake2 bugfix
+ if (cluster == -1)
+ return false;
if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7)))))
return false;
@@ -293,7 +296,10 @@ public class SV_GAME extends SV_INIT {
cluster = CM.CM_LeafCluster(leafnum);
area2 = CM.CM_LeafArea(leafnum);
- if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7)))))
+ // quake2 bugfix
+ if (cluster == -1)
+ return false;
+ if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7)))))
return false; // more than one bounce away
if (!CM.CM_AreasConnected(area1, area2))
return false; // a door blocks hearing
diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java
index 8fcfa37..b4b4ee6 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.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_INIT.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
package jake2.server;
@@ -115,7 +115,7 @@ public class SV_INIT extends Globals {
//
VectorCopy(svent.s.origin, svent.s.old_origin);
// rst: bugfix
- sv.baselines[entnum] = svent.s.getClone();
+ sv.baselines[entnum].set(svent.s);// = svent.s.getClone();
}
}
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index ca6b07e..747f2d4 100644
--- a/src/jake2/server/SV_SEND.java
+++ b/src/jake2/server/SV_SEND.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_SEND.java,v 1.1 2004-07-07 19:59:49 hzi Exp $
+// $Id: SV_SEND.java,v 1.2 2004-07-08 20:24:30 hzi Exp $
package jake2.server;
@@ -232,6 +232,10 @@ public class SV_SEND extends SV_MAIN {
area2 = CM.CM_LeafArea(leafnum);
if (!CM.CM_AreasConnected(area1, area2))
continue;
+
+ // quake2 bugfix
+ if (cluster == -1)
+ continue;
if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7)))))
continue;
}
diff --git a/src/jake2/server/SV_USER.java b/src/jake2/server/SV_USER.java
index 1136d20..c6e355e 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.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_USER.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
package jake2.server;
@@ -308,11 +308,10 @@ public class SV_USER extends SV_SEND {
|| allow_download.value == 0 // leading dot is no good
|| name.charAt(0) == '.' // leading slash bad as well, must be in subdir
|| name.charAt(0) == '/' // next up, skin check
- || (strncmp(name, "players/", 6) == 0 && 0 == allow_download_players.value) // now models
- || (strncmp(name, "models/", 6) == 0 && 0 == allow_download_models.value) // now sounds
- || (strncmp(name, "sound/", 6) == 0
- && 0 == allow_download_sounds.value) // now maps (note special case for maps, must not be in pak)
- || (strncmp(name, "maps/", 6) == 0 && 0 == allow_download_maps.value) // MUST be in a subdirectory
+ || (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("maps/") && 0 == allow_download_maps.value) // MUST be in a subdirectory
|| name.indexOf('/') == -1) { // don't allow anything with .. path
MSG.WriteByte(sv_client.netchan.message, svc_download);
MSG.WriteShort(sv_client.netchan.message, -1);
@@ -332,7 +331,7 @@ public class SV_USER extends SV_SEND {
if (sv_client.download == null // special check for maps, if it came from a pak file, don't allow
// download ZOID
- || (strncmp(name, "maps/", 5) == 0 && 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) {
FS.FreeFile(sv_client.download);
diff --git a/src/jake2/server/SV_WORLD.java b/src/jake2/server/SV_WORLD.java
index a400959..4e78084 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.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_WORLD.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
package jake2.server;
@@ -607,7 +607,7 @@ public class SV_WORLD extends SV_CCMDS
clip.trace.startsolid = true;
}
else
- clip.trace = trace.getClone();
+ clip.trace.set(trace);
}
else if (trace.startsolid)
clip.trace.startsolid = true;
diff --git a/src/jake2/sys/Sys.java b/src/jake2/sys/Sys.java
index 5e8c0df..8a08956 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.2 2004-07-08 15:58:47 hzi Exp $
+ * $Id: Sys.java,v 1.3 2004-07-08 20:24:30 hzi Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -202,7 +202,7 @@ public final class Sys extends Defines {
return 0;
}
- return Globals.curtime = (int) (Globals.slomo.value * (System.currentTimeMillis() - secbase));
+ return Globals.curtime = (int) (System.currentTimeMillis() - secbase);
}
diff --git a/src/jake2/util/Math3D.java b/src/jake2/util/Math3D.java
index 6c607b3..fcdeaee 100644
--- a/src/jake2/util/Math3D.java
+++ b/src/jake2/util/Math3D.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Math3D.java,v 1.2 2004-07-08 15:58:48 hzi Exp $
+// $Id: Math3D.java,v 1.3 2004-07-08 20:24:31 hzi Exp $
package jake2.util;
@@ -33,8 +33,9 @@ public class Math3D extends Lib {
static final float piratio = (float)(Math.PI / 360.0);
public static void set(float v1[], float v2[]) {
- for (int i = 0; i < v1.length; i++)
- v1[i] = v2[i];
+ v1[0] = v2[0];
+ v1[1] = v2[1];
+ v1[2] = v2[2];
}
@@ -105,11 +106,10 @@ public class Math3D extends Lib {
to[2] = veca[2] + scale * vecb[2];
}
public static final float VectorNormalize(float[] v) {
- float length, ilength;
- length = VectorLength(v);
+ float length = VectorLength(v);
if (length != 0.0f) {
- ilength = 1.0f / length;
+ float ilength = 1.0f / length;
v[0] *= ilength;
v[1] *= ilength;
v[2] *= ilength;
@@ -164,7 +164,7 @@ public class Math3D extends Lib {
}
public static void vectoangles(float[] value1, float[] angles) {
- float forward;
+
float yaw, pitch;
if (value1[1] == 0 && value1[0] == 0) {
@@ -184,7 +184,7 @@ public class Math3D extends Lib {
if (yaw < 0)
yaw += 360;
- forward = (float) Math.sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
+ float forward = (float) Math.sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
pitch = (int) (Math.atan2(value1[2], forward) * 180 / Math.PI);
if (pitch < 0)
pitch += 360;
@@ -195,13 +195,18 @@ public class Math3D extends Lib {
angles[Defines.ROLL] = 0;
}
- public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) {
- float m[][] = new float[3][3];
- float im[][] = new float[3][3];
- float zrot[][] = new float[3][3];
- float tmpmat[][] = new float[3][3];
- float rot[][] = new float[3][3];
- int i;
+ private static float m[][] = new float[3][3];
+ private static float im[][] = new float[3][3];
+ private static float tmpmat[][] = new float[3][3];
+ private static float zrot[][] = new float[3][3];
+ public static void RotatePointAroundVector(float[] dst, float[] dir, float[] point, float degrees) {
+
+ //float m[][] = new float[3][3];
+ //float im[][] = new float[3][3];
+ //float zrot[][] = new float[3][3];
+ //float tmpmat[][] = new float[3][3];
+ //float rot[][] = new float[3][3];
+
float[] vr = { 0.0f, 0.0f, 0.0f };
float[] vup = { 0.0f, 0.0f, 0.0f };
float[] vf = { 0.0f, 0.0f, 0.0f };
@@ -225,29 +230,33 @@ public class Math3D extends Lib {
m[1][2] = vf[1];
m[2][2] = vf[2];
- Math3D.MatCopy(m, im); // achtung: src -> dst
+ //Math3D.MatCopy(m, im); // achtung: src -> dst
+ im[0][0] = m[0][0];
im[0][1] = m[1][0];
im[0][2] = m[2][0];
im[1][0] = m[0][1];
+ im[1][1] = m[1][1];
im[1][2] = m[2][1];
im[2][0] = m[0][2];
im[2][1] = m[1][2];
+ im[2][2] = m[2][2];
- Math3D.MatClear(zrot);
+ zrot[0][2] = zrot[1][2] = zrot[2][0] = zrot[2][1] = 0.0f;
- zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F;
+ zrot[2][2] = 1.0F;
- zrot[0][0] = (float) Math.cos(Math3D.DEG2RAD(degrees));
+ zrot[0][0] = zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees));
zrot[0][1] = (float) Math.sin(Math3D.DEG2RAD(degrees));
- zrot[1][0] = - (float) Math.sin(Math3D.DEG2RAD(degrees));
- zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees));
+ zrot[1][0] = -zrot[0][1];
+ //zrot[1][0] = - (float) Math.sin(Math3D.DEG2RAD(degrees));
+ //zrot[1][1] = (float) Math.cos(Math3D.DEG2RAD(degrees));
Math3D.R_ConcatRotations(m, zrot, tmpmat);
- Math3D.R_ConcatRotations(tmpmat, im, rot);
+ Math3D.R_ConcatRotations(tmpmat, im, zrot);
- for (i = 0; i < 3; i++) {
- dst[i] = rot[i][0] * point[0] + rot[i][1] * point[1] + rot[i][2] * point[2];
+ for (int i = 0; i < 3; i++) {
+ dst[i] = zrot[i][0] * point[0] + zrot[i][1] * point[1] + zrot[i][2] * point[2];
}
}
@@ -328,7 +337,7 @@ public class Math3D extends Lib {
int pos;
int i;
float minelem = 1.0F;
- float tempvec[] = { 0.0f, 0.0f, 0.0f };
+
// find the smallest magnitude axially aligned vector
for (pos = 0, i = 0; i < 3; i++) {
@@ -337,7 +346,7 @@ public class Math3D extends Lib {
minelem = Math.abs(src[i]);
}
}
- tempvec[0] = tempvec[1] = tempvec[2] = 0.0F;
+ float tempvec[] = { 0.0f, 0.0f, 0.0f };
tempvec[pos] = 1.0F;
// project the point onto the plane defined by src
@@ -421,13 +430,11 @@ public class Math3D extends Lib {
}
// this is the slow, general version
+ private static float corners[][] = new float[2][3];
public static final int BoxOnPlaneSide2(float[] emins, float[] emaxs, cplane_t p) {
- int i;
- float dist1, dist2;
- int sides;
- float corners[][] = new float[2][3];
+
- for (i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
if (p.normal[i] < 0) {
corners[0][i] = emins[i];
corners[1][i] = emaxs[i];
@@ -437,9 +444,9 @@ public class Math3D extends Lib {
corners[0][i] = emaxs[i];
}
}
- dist1 = Math3D.DotProduct(p.normal, corners[0]) - p.dist;
- dist2 = Math3D.DotProduct(p.normal, corners[1]) - p.dist;
- sides = 0;
+ float dist1 = Math3D.DotProduct(p.normal, corners[0]) - p.dist;
+ float dist2 = Math3D.DotProduct(p.normal, corners[1]) - p.dist;
+ int sides = 0;
if (dist1 >= 0)
sides = 1;
if (dist2 < 0)
@@ -479,21 +486,21 @@ public class Math3D extends Lib {
}
}
- public static void MatClear(float m[][]) {
- m[0][0] = m[0][1] = m[0][2] = m[1][0] = m[1][1] = m[1][2] = m[2][0] = m[2][1] = m[2][2] = 0.0f;
- }
+// public static void MatClear(float m[][]) {
+// m[0][0] = m[0][1] = m[0][2] = m[1][0] = m[1][1] = m[1][2] = m[2][0] = m[2][1] = m[2][2] = 0.0f;
+// }
- private static final void MatCopy(float src[][], float dst[][]) {
- dst[0][0]=src[0][0];
- dst[0][1]=src[0][1];
- dst[0][2]=src[0][2];
- dst[1][0]=src[1][0];
- dst[1][1]=src[1][1];
- dst[1][2]=src[1][2];
- dst[2][0]=src[2][0];
- dst[2][1]=src[2][1];
- dst[2][2]=src[2][2];
- }
+// private static final void MatCopy(float src[][], float dst[][]) {
+// dst[0][0]=src[0][0];
+// dst[0][1]=src[0][1];
+// dst[0][2]=src[0][2];
+// dst[1][0]=src[1][0];
+// dst[1][1]=src[1][1];
+// dst[1][2]=src[1][2];
+// dst[2][0]=src[2][0];
+// dst[2][1]=src[2][1];
+// dst[2][2]=src[2][2];
+// }
public static void G_ProjectSource(float[] point, float[] distance, float[] forward, float[] right, float[] result) {
result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1];
@@ -503,7 +510,7 @@ public class Math3D extends Lib {
- public static float DotProduct(float[] x, float[] y) {
+ public static final float DotProduct(float[] x, float[] y) {
return x[0] * y[0] + x[1] * y[1] + x[2] * y[2];
}