aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/client
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-08 20:24:48 +0000
committerHolger Zickner <[email protected]>2004-07-08 20:24:48 +0000
commit252832999fa43bce63ca4b643fab5d9dd51fccc4 (patch)
tree98570c65819059d14f0809ae964aa1c6c93684a0 /src/jake2/client
parent4f13ea26c4f47e54e66926f0700cf631e7bb3352 (diff)
import of Jake2 version cebit
Diffstat (limited to 'src/jake2/client')
-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
16 files changed, 612 insertions, 605 deletions
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;