aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
authorRene Stoeckel <[email protected]>2004-08-22 14:25:15 +0000
committerRene Stoeckel <[email protected]>2004-08-22 14:25:15 +0000
commitd9518e2c5da7bdf3eb8a80f882c31234d0734673 (patch)
treea2c0c9a3665a4ece7620c2df417b173502231fb5 /src/jake2
parent93a1cb6d6bfa9d7a80c004100125c829f1f36e86 (diff)
cleanups and base3 bugfix for the load and save routines.
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/client/SCR.java2019
-rw-r--r--src/jake2/game/GameBase.java530
-rw-r--r--src/jake2/game/GameFuncAdapters.java1151
-rw-r--r--src/jake2/game/GameSave.java296
-rw-r--r--src/jake2/game/edict_t.java127
-rw-r--r--src/jake2/game/game_export_t.java78
-rw-r--r--src/jake2/game/game_import_t.java4
-rw-r--r--src/jake2/qcommon/PMove.java4
-rw-r--r--src/jake2/render/fastjogl/Draw.java4
-rw-r--r--src/jake2/server/SV.java4
-rw-r--r--src/jake2/server/SV_CCMDS.java449
-rw-r--r--src/jake2/server/SV_GAME.java33
-rw-r--r--src/jake2/server/SV_INIT.java133
-rw-r--r--src/jake2/server/SV_SEND.java143
-rw-r--r--src/jake2/server/client_t.java5
15 files changed, 2103 insertions, 2877 deletions
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index 5df826c..da19b29 100644
--- a/src/jake2/client/SCR.java
+++ b/src/jake2/client/SCR.java
@@ -2,7 +2,7 @@
* SCR.java
* Copyright (C) 2003
*
- * $Id: SCR.java,v 1.5 2004-07-09 06:50:50 hzi Exp $
+ * $Id: SCR.java,v 1.6 2004-08-22 14:25:15 salomo Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -39,12 +39,11 @@ import java.awt.Dimension;
/**
* SCR
*/
-public final class SCR extends Globals
-{
+public final class SCR extends Globals {
// cl_scrn.c -- master for refresh, status bar, console, chat, notify, etc
- static String[][] sb_nums =
+ static String[][] sb_nums=
{ { "num_0", "num_1", "num_2", "num_3", "num_4", "num_5", "num_6", "num_7", "num_8", "num_9", "num_minus" }, {
"anum_0", "anum_1", "anum_2", "anum_3", "anum_4", "anum_5", "anum_6", "anum_7", "anum_8", "anum_9", "anum_minus" }
};
@@ -86,28 +85,27 @@ public final class SCR extends Globals
static cvar_t scr_drawall;
public static cvar_t fps;
- static dirty_t scr_dirty = new dirty_t();
- static dirty_t[] scr_old_dirty = { new dirty_t(), new dirty_t()};
+ static dirty_t scr_dirty= new dirty_t();
+ static dirty_t[] scr_old_dirty= { new dirty_t(), new dirty_t()};
static String crosshair_pic;
static int crosshair_width, crosshair_height;
- static class dirty_t
- {
+ static class dirty_t {
int x1;
int x2;
int y1;
int y2;
-
+
void set(dirty_t src) {
- x1 = src.x1;
- x2 = src.x2;
- y1 = src.y1;
- y2 = src.y2;
+ x1= src.x1;
+ x2= src.x2;
+ y1= src.y1;
+ y2= src.y2;
}
-
+
void clear() {
- x1 = x2 = y1 = y2 = 0;
+ x1= x2= y1= y2= 0;
}
}
@@ -124,17 +122,16 @@ public final class SCR extends Globals
// float value;
// int color;
// } graphsamp_t;
- static class graphsamp_t
- {
+ static class graphsamp_t {
float value;
int color;
}
static int current;
- static graphsamp_t[] values = new graphsamp_t[1024];
+ static graphsamp_t[] values= new graphsamp_t[1024];
static {
- for (int n = 0; n < 1024; n++)
- values[n] = new graphsamp_t();
+ for (int n= 0; n < 1024; n++)
+ values[n]= new graphsamp_t();
}
/*
@@ -142,10 +139,9 @@ public final class SCR extends Globals
SCR_DebugGraph
==============
*/
- public static void DebugGraph(float value, int color)
- {
- values[current & 1023].value = value;
- values[current & 1023].color = color;
+ public static void DebugGraph(float value, int color) {
+ values[current & 1023].value= value;
+ values[current & 1023].color= color;
current++;
}
@@ -154,30 +150,28 @@ public final class SCR extends Globals
SCR_DrawDebugGraph
==============
*/
- static void DrawDebugGraph()
- {
+ static void DrawDebugGraph() {
int a, x, y, w, i, h;
float v;
int color;
// draw the graph
- w = scr_vrect.width;
+ w= scr_vrect.width;
- x = scr_vrect.x;
- y = scr_vrect.y + scr_vrect.height;
+ x= scr_vrect.x;
+ y= scr_vrect.y + scr_vrect.height;
re.DrawFill(x, (int) (y - scr_graphheight.value), w, (int) scr_graphheight.value, 8);
- for (a = 0; a < w; a++)
- {
- i = (current - 1 - a + 1024) & 1023;
- v = values[i].value;
- color = values[i].color;
- v = v * scr_graphscale.value + scr_graphshift.value;
+ for (a= 0; a < w; a++) {
+ i= (current - 1 - a + 1024) & 1023;
+ v= values[i].value;
+ color= values[i].color;
+ v= v * scr_graphscale.value + scr_graphshift.value;
if (v < 0)
v += scr_graphheight.value * (1 + (int) (-v / scr_graphheight.value));
- h = (int) v % (int) scr_graphheight.value;
+ h= (int) v % (int) scr_graphheight.value;
re.DrawFill(x + w - 1 - a, y - h, 1, h, color);
}
}
@@ -205,23 +199,21 @@ public final class SCR extends Globals
for a few moments
==============
*/
- static void CenterPrint(String str)
- {
+ static void CenterPrint(String str) {
//char *s;
int s;
- StringBuffer line = new StringBuffer(64);
+ StringBuffer line= new StringBuffer(64);
int i, j, l;
//strncpy (scr_centerstring, str, sizeof(scr_centerstring)-1);
- scr_centerstring = str;
- scr_centertime_off = scr_centertime.value;
- scr_centertime_start = cl.time;
+ scr_centerstring= str;
+ scr_centertime_off= scr_centertime.value;
+ scr_centertime_start= cl.time;
// count the number of lines for centering
- scr_center_lines = 1;
- s = 0;
- while (s < str.length())
- {
+ scr_center_lines= 1;
+ s= 0;
+ while (s < str.length()) {
if (str.charAt(s) == '\n')
scr_center_lines++;
s++;
@@ -231,22 +223,19 @@ public final class SCR extends Globals
Com.Printf(
"\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
- s = 0;
+ s= 0;
- if (str.length() != 0)
- {
- do
- {
+ if (str.length() != 0) {
+ do {
// scan the width of the line
- for (l = 0; l < 40 && (l + s) < str.length(); l++)
+ for (l= 0; l < 40 && (l + s) < str.length(); l++)
if (str.charAt(s + l) == '\n' || str.charAt(s + l) == 0)
break;
- for (i = 0; i < (40 - l) / 2; i++)
+ for (i= 0; i < (40 - l) / 2; i++)
line.append(' ');
- for (j = 0; j < l; j++)
- {
+ for (j= 0; j < l; j++) {
line.append(str.charAt(s + j));
}
@@ -268,9 +257,8 @@ public final class SCR extends Globals
Console.ClearNotify();
}
- static void DrawCenterString()
- {
- String cs = scr_centerstring + "\0";
+ static void DrawCenterString() {
+ String cs= scr_centerstring + "\0";
int start;
int l;
int j;
@@ -283,26 +271,24 @@ public final class SCR extends Globals
return;
// the finale prints the characters one at a time
- remaining = 9999;
+ remaining= 9999;
- scr_erase_center = 0;
- start = 0;
+ scr_erase_center= 0;
+ start= 0;
if (scr_center_lines <= 4)
- y = (int) (viddef.height * 0.35);
+ y= (int) (viddef.height * 0.35);
else
- y = 48;
+ y= 48;
- do
- {
+ do {
// scan the width of the line
- for (l = 0; l < 40; l++)
+ for (l= 0; l < 40; l++)
if (start + l == cs.length() - 1 || cs.charAt(start + l) == '\n')
break;
- x = (viddef.width - l * 8) / 2;
+ x= (viddef.width - l * 8) / 2;
SCR.AddDirtyPoint(x, y);
- for (j = 0; j < l; j++, x += 8)
- {
+ for (j= 0; j < l; j++, x += 8) {
re.DrawChar(x, y, cs.charAt(start + j));
if (remaining == 0)
return;
@@ -322,8 +308,7 @@ public final class SCR extends Globals
while (true);
}
- static void CheckDrawCenterString()
- {
+ static void CheckDrawCenterString() {
scr_centertime_off -= cls.frametime;
if (scr_centertime_off <= 0)
@@ -341,8 +326,7 @@ public final class SCR extends Globals
Sets scr_vrect, the coordinates of the rendered window
=================
*/
- static void CalcVrect()
- {
+ static void CalcVrect() {
int size;
// bound viewsize
@@ -351,16 +335,16 @@ public final class SCR extends Globals
if (scr_viewsize.value > 100)
Cvar.Set("viewsize", "100");
- size = (int) scr_viewsize.value;
+ size= (int) scr_viewsize.value;
- scr_vrect.width = viddef.width * size / 100;
+ scr_vrect.width= viddef.width * size / 100;
scr_vrect.width &= ~7;
- scr_vrect.height = viddef.height * size / 100;
+ scr_vrect.height= viddef.height * size / 100;
scr_vrect.height &= ~1;
- scr_vrect.x = (viddef.width - scr_vrect.width) / 2;
- scr_vrect.y = (viddef.height - scr_vrect.height) / 2;
+ scr_vrect.x= (viddef.width - scr_vrect.width) / 2;
+ scr_vrect.y= (viddef.height - scr_vrect.height) / 2;
}
/*
@@ -370,8 +354,7 @@ public final class SCR extends Globals
Keybinding command
=================
*/
- static void SizeUp_f()
- {
+ static void SizeUp_f() {
Cvar.SetValue("viewsize", scr_viewsize.value + 10);
}
@@ -382,8 +365,7 @@ public final class SCR extends Globals
Keybinding command
=================
*/
- static void SizeDown_f()
- {
+ static void SizeDown_f() {
Cvar.SetValue("viewsize", scr_viewsize.value - 10);
}
@@ -394,31 +376,27 @@ public final class SCR extends Globals
Set a specific sky and rotation speed
=================
*/
- static void Sky_f()
- {
+ static void Sky_f() {
float rotate;
- float[] axis = { 0, 0, 0 };
+ float[] axis= { 0, 0, 0 };
- if (Cmd.Argc() < 2)
- {
+ if (Cmd.Argc() < 2) {
Com.Printf("Usage: sky <basename> <rotate> <axis x y z>\n");
return;
}
if (Cmd.Argc() > 2)
- rotate = Float.parseFloat(Cmd.Argv(2));
+ rotate= Float.parseFloat(Cmd.Argv(2));
else
- rotate = 0;
- if (Cmd.Argc() == 6)
- {
- axis[0] = Float.parseFloat(Cmd.Argv(3));
- axis[1] = Float.parseFloat(Cmd.Argv(4));
- axis[2] = Float.parseFloat(Cmd.Argv(5));
+ rotate= 0;
+ if (Cmd.Argc() == 6) {
+ axis[0]= Float.parseFloat(Cmd.Argv(3));
+ axis[1]= Float.parseFloat(Cmd.Argv(4));
+ axis[2]= Float.parseFloat(Cmd.Argv(5));
}
- else
- {
- axis[0] = 0;
- axis[1] = 0;
- axis[2] = 1;
+ else {
+ axis[0]= 0;
+ axis[1]= 0;
+ axis[2]= 1;
}
re.SetSky(Cmd.Argv(1), rotate, axis);
@@ -431,63 +409,52 @@ public final class SCR extends Globals
SCR_Init
==================
*/
- static void Init()
- {
- scr_viewsize = Cvar.Get("viewsize", "100", CVAR_ARCHIVE);
- scr_conspeed = Cvar.Get("scr_conspeed", "3", 0);
- scr_showturtle = Cvar.Get("scr_showturtle", "0", 0);
- scr_showpause = Cvar.Get("scr_showpause", "1", 0);
- scr_centertime = Cvar.Get("scr_centertime", "2.5", 0);
- scr_printspeed = Cvar.Get("scr_printspeed", "8", 0);
- scr_netgraph = Cvar.Get("netgraph", "1", 0);
- scr_timegraph = Cvar.Get("timegraph", "1", 0);
- scr_debuggraph = Cvar.Get("debuggraph", "1", 0);
- scr_graphheight = Cvar.Get("graphheight", "32", 0);
- scr_graphscale = Cvar.Get("graphscale", "1", 0);
- scr_graphshift = Cvar.Get("graphshift", "0", 0);
- scr_drawall = Cvar.Get("scr_drawall", "1", 0);
- fps = Cvar.Get("fps", "0", 0);
+ static void Init() {
+ scr_viewsize= Cvar.Get("viewsize", "100", CVAR_ARCHIVE);
+ scr_conspeed= Cvar.Get("scr_conspeed", "3", 0);
+ scr_showturtle= Cvar.Get("scr_showturtle", "0", 0);
+ scr_showpause= Cvar.Get("scr_showpause", "1", 0);
+ scr_centertime= Cvar.Get("scr_centertime", "2.5", 0);
+ scr_printspeed= Cvar.Get("scr_printspeed", "8", 0);
+ scr_netgraph= Cvar.Get("netgraph", "1", 0);
+ scr_timegraph= Cvar.Get("timegraph", "1", 0);
+ scr_debuggraph= Cvar.Get("debuggraph", "1", 0);
+ scr_graphheight= Cvar.Get("graphheight", "32", 0);
+ scr_graphscale= Cvar.Get("graphscale", "1", 0);
+ scr_graphshift= Cvar.Get("graphshift", "0", 0);
+ scr_drawall= Cvar.Get("scr_drawall", "1", 0);
+ fps= Cvar.Get("fps", "0", 0);
//
// register our commands
//
- Cmd.AddCommand("timerefresh", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("timerefresh", new xcommand_t() {
+ public void execute() {
TimeRefresh_f();
}
});
- Cmd.AddCommand("loading", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("loading", new xcommand_t() {
+ public void execute() {
Loading_f();
}
});
- Cmd.AddCommand("sizeup", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("sizeup", new xcommand_t() {
+ public void execute() {
SizeUp_f();
}
});
- Cmd.AddCommand("sizedown", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("sizedown", new xcommand_t() {
+ public void execute() {
SizeDown_f();
}
});
- Cmd.AddCommand("sky", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("sky", new xcommand_t() {
+ public void execute() {
Sky_f();
}
});
- scr_initialized = true;
+ scr_initialized= true;
}
/*
@@ -495,8 +462,7 @@ public final class SCR extends Globals
SCR_DrawNet
==============
*/
- static void DrawNet()
- {
+ static void DrawNet() {
if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP - 1)
return;
@@ -508,9 +474,8 @@ public final class SCR extends Globals
SCR_DrawPause
==============
*/
- static void DrawPause()
- {
- Dimension dim = new Dimension();
+ static void DrawPause() {
+ Dimension dim= new Dimension();
if (scr_showpause.value == 0) // turn off for screenshots
return;
@@ -527,14 +492,13 @@ public final class SCR extends Globals
SCR_DrawLoading
==============
*/
- static void DrawLoading()
- {
- Dimension dim = new Dimension();
+ static void DrawLoading() {
+ Dimension dim= new Dimension();
if (scr_draw_loading == 0)
return;
- scr_draw_loading = 0;
+ scr_draw_loading= 0;
re.DrawGetPicSize(dim, "loading");
re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading");
}
@@ -548,26 +512,23 @@ public final class SCR extends Globals
Scroll it up or down
==================
*/
- static void RunConsole()
- {
+ static void RunConsole() {
// decide on the height of the console
if (cls.key_dest == key_console)
- scr_conlines = 0.5f; // half screen
+ scr_conlines= 0.5f; // half screen
else
- scr_conlines = 0; // none visible
+ scr_conlines= 0; // none visible
- if (scr_conlines < scr_con_current)
- {
+ if (scr_conlines < scr_con_current) {
scr_con_current -= scr_conspeed.value * cls.frametime;
if (scr_conlines > scr_con_current)
- scr_con_current = scr_conlines;
+ scr_con_current= scr_conlines;
}
- else if (scr_conlines > scr_con_current)
- {
+ else if (scr_conlines > scr_con_current) {
scr_con_current += scr_conspeed.value * cls.frametime;
if (scr_conlines < scr_con_current)
- scr_con_current = scr_conlines;
+ scr_con_current= scr_conlines;
}
}
@@ -576,29 +537,24 @@ public final class SCR extends Globals
SCR_DrawConsole
==================
*/
- static void DrawConsole()
- {
+ static void DrawConsole() {
Console.CheckResize();
- if (cls.state == ca_disconnected || cls.state == ca_connecting)
- { // forced full screen console
+ if (cls.state == ca_disconnected || cls.state == ca_connecting) { // forced full screen console
Console.DrawConsole(1.0f);
return;
}
- if (cls.state != ca_active || !cl.refresh_prepped)
- { // connected, but can't render
+ if (cls.state != ca_active || !cl.refresh_prepped) { // connected, but can't render
Console.DrawConsole(0.5f);
re.DrawFill(0, viddef.height / 2, viddef.width, viddef.height / 2, 0);
return;
}
- if (scr_con_current != 0)
- {
+ if (scr_con_current != 0) {
Console.DrawConsole(scr_con_current);
}
- else
- {
+ else {
if (cls.key_dest == key_game || cls.key_dest == key_message)
Console.DrawNotify(); // only draw notify in game
}
@@ -611,10 +567,9 @@ public final class SCR extends Globals
SCR_BeginLoadingPlaque
================
*/
- public static void BeginLoadingPlaque()
- {
+ public static void BeginLoadingPlaque() {
S.StopAllSounds();
- cl.sound_prepped = false; // don't play ambients
+ cl.sound_prepped= false; // don't play ambients
if (cls.disable_screen != 0)
return;
@@ -625,13 +580,13 @@ public final class SCR extends Globals
if (cls.key_dest == key_console)
return;
if (cl.cinematictime > 0)
- scr_draw_loading = 2; // clear to balack first
+ scr_draw_loading= 2; // clear to balack first
else
- scr_draw_loading = 1;
+ scr_draw_loading= 1;
UpdateScreen();
- cls.disable_screen = Sys.Milliseconds();
- cls.disable_servercount = cl.servercount;
+ cls.disable_screen= Sys.Milliseconds();
+ cls.disable_servercount= cl.servercount;
}
/*
@@ -639,9 +594,8 @@ public final class SCR extends Globals
SCR_EndLoadingPlaque
================
*/
- public static void EndLoadingPlaque()
- {
- cls.disable_screen = 0;
+ public static void EndLoadingPlaque() {
+ cls.disable_screen= 0;
Console.ClearNotify();
}
@@ -650,8 +604,7 @@ public final class SCR extends Globals
SCR_Loading_f
================
*/
- static void Loading_f()
- {
+ static void Loading_f() {
BeginLoadingPlaque();
}
@@ -660,8 +613,7 @@ public final class SCR extends Globals
SCR_TimeRefresh_f
================
*/
- static void TimeRefresh_f()
- {
+ static void TimeRefresh_f() {
int i;
int start, stop;
float time;
@@ -669,23 +621,19 @@ public final class SCR extends Globals
if (cls.state != ca_active)
return;
- start = Sys.Milliseconds();
+ start= Sys.Milliseconds();
- if (Cmd.Argc() == 2)
- { // run without page flipping
+ if (Cmd.Argc() == 2) { // run without page flipping
re.BeginFrame(0);
- for (i = 0; i < 128; i++)
- {
- cl.refdef.viewangles[1] = i / 128.0f * 360.0f;
+ for (i= 0; i < 128; i++) {
+ cl.refdef.viewangles[1]= i / 128.0f * 360.0f;
re.RenderFrame(cl.refdef);
}
re.EndFrame();
}
- else
- {
- for (i = 0; i < 128; i++)
- {
- cl.refdef.viewangles[1] = i / 128.0f * 360.0f;
+ else {
+ for (i= 0; i < 128; i++) {
+ cl.refdef.viewangles[1]= i / 128.0f * 360.0f;
re.BeginFrame(0);
re.RenderFrame(cl.refdef);
@@ -693,13 +641,12 @@ public final class SCR extends Globals
}
}
- stop = Sys.Milliseconds();
- time = (stop - start) / 1000.0f;
+ stop= Sys.Milliseconds();
+ time= (stop - start) / 1000.0f;
Com.Printf("%f seconds (%f fps)\n", new Vargs(2).add(time).add(128.0f / time));
}
- static void DirtyScreen()
- {
+ static void DirtyScreen() {
AddDirtyPoint(0, 0);
AddDirtyPoint(viddef.width - 1, viddef.height - 1);
}
@@ -712,10 +659,9 @@ public final class SCR extends Globals
==============
*/
- static dirty_t clear = new dirty_t();
+ static dirty_t clear= new dirty_t();
- static void TileClear()
- {
+ static void TileClear() {
int i;
int top, bottom, left, right;
clear.clear();
@@ -733,74 +679,69 @@ public final class SCR extends Globals
// erase rect will be the union of the past three frames
// so tripple buffering works properly
clear.set(scr_dirty);
- for (i = 0; i < 2; i++)
- {
+ for (i= 0; i < 2; i++) {
if (scr_old_dirty[i].x1 < clear.x1)
- clear.x1 = scr_old_dirty[i].x1;
+ clear.x1= scr_old_dirty[i].x1;
if (scr_old_dirty[i].x2 > clear.x2)
- clear.x2 = scr_old_dirty[i].x2;
+ clear.x2= scr_old_dirty[i].x2;
if (scr_old_dirty[i].y1 < clear.y1)
- clear.y1 = scr_old_dirty[i].y1;
+ clear.y1= scr_old_dirty[i].y1;
if (scr_old_dirty[i].y2 > clear.y2)
- clear.y2 = scr_old_dirty[i].y2;
+ clear.y2= scr_old_dirty[i].y2;
}
scr_old_dirty[1].set(scr_old_dirty[0]);
scr_old_dirty[0].set(scr_dirty);
- scr_dirty.x1 = 9999;
- scr_dirty.x2 = -9999;
- scr_dirty.y1 = 9999;
- scr_dirty.y2 = -9999;
+ scr_dirty.x1= 9999;
+ scr_dirty.x2= -9999;
+ scr_dirty.y1= 9999;
+ scr_dirty.y2= -9999;
// don't bother with anything convered by the console)
- top = (int) (scr_con_current * viddef.height);
+ top= (int) (scr_con_current * viddef.height);
if (top >= clear.y1)
- clear.y1 = top;
+ clear.y1= top;
if (clear.y2 <= clear.y1)
return; // nothing disturbed
- top = scr_vrect.y;
- bottom = top + scr_vrect.height - 1;
- left = scr_vrect.x;
- right = left + scr_vrect.width - 1;
+ top= scr_vrect.y;
+ bottom= top + scr_vrect.height - 1;
+ left= scr_vrect.x;
+ right= left + scr_vrect.width - 1;
- if (clear.y1 < top)
- { // clear above view screen
- i = clear.y2 < top - 1 ? clear.y2 : top - 1;
+ if (clear.y1 < top) { // clear above view screen
+ i= clear.y2 < top - 1 ? clear.y2 : top - 1;
re.DrawTileClear(clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1, "backtile");
- clear.y1 = top;
+ clear.y1= top;
}
- if (clear.y2 > bottom)
- { // clear below view screen
- i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
+ if (clear.y2 > bottom) { // clear below view screen
+ i= clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
re.DrawTileClear(clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1, "backtile");
- clear.y2 = bottom;
+ clear.y2= bottom;
}
- if (clear.x1 < left)
- { // clear left of view screen
- i = clear.x2 < left - 1 ? clear.x2 : left - 1;
+ if (clear.x1 < left) { // clear left of view screen
+ i= clear.x2 < left - 1 ? clear.x2 : left - 1;
re.DrawTileClear(clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1, "backtile");
- clear.x1 = left;
+ clear.x1= left;
}
- if (clear.x2 > right)
- { // clear left of view screen
- i = clear.x1 > right + 1 ? clear.x1 : right + 1;
+ if (clear.x2 > right) { // clear left of view screen
+ i= clear.x1 > right + 1 ? clear.x1 : right + 1;
re.DrawTileClear(i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1, "backtile");
- clear.x2 = right;
+ clear.x2= right;
}
}
// ===============================================================
- static final int STAT_MINUS = 10; // num frame for '-' stats digit
+ static final int STAT_MINUS= 10; // num frame for '-' stats digit
- static final int ICON_WIDTH = 24;
- static final int ICON_HEIGHT = 24;
- static final int CHAR_WIDTH = 16;
- static final int ICON_SPACE = 8;
+ static final int ICON_WIDTH= 24;
+ static final int ICON_HEIGHT= 24;
+ static final int CHAR_WIDTH= 16;
+ static final int ICON_SPACE= 8;
/*
================
@@ -809,64 +750,56 @@ public final class SCR extends Globals
Allow embedded \n in the string
================
*/
- static void SizeHUDString(String string, Dimension dim)
- {
+ static void SizeHUDString(String string, Dimension dim) {
int lines, width, current;
- lines = 1;
- width = 0;
+ lines= 1;
+ width= 0;
- current = 0;
- for (int i = 0; i < string.length(); i++)
- {
- if (string.charAt(i) == '\n')
- {
+ current= 0;
+ for (int i= 0; i < string.length(); i++) {
+ if (string.charAt(i) == '\n') {
lines++;
- current = 0;
+ current= 0;
}
- else
- {
+ else {
current++;
if (current > width)
- width = current;
+ width= current;
}
}
- dim.width = width * 8;
- dim.height = lines * 8;
+ dim.width= width * 8;
+ dim.height= lines * 8;
}
- static void DrawHUDString(String string, int x, int y, int centerwidth, int xor)
- {
+ static void DrawHUDString(String string, int x, int y, int centerwidth, int xor) {
int margin;
//char line[1024];
- StringBuffer line = new StringBuffer(1024);
+ StringBuffer line= new StringBuffer(1024);
int i;
- margin = x;
+ margin= x;
- for (int l = 0; l < string.length();)
- {
+ for (int l= 0; l < string.length();) {
// scan out one line of text from the string
- line = new StringBuffer(1024);
+ line= new StringBuffer(1024);
while (string.charAt(l) != '\n')
line.append(string.charAt(l));
l++;
if (centerwidth != 0)
- x = margin + (centerwidth - line.length() * 8) / 2;
+ x= margin + (centerwidth - line.length() * 8) / 2;
else
- x = margin;
- for (i = 0; i < line.length(); i++)
- {
+ x= margin;
+ for (i= 0; i < line.length(); i++) {
re.DrawChar(x, y, line.charAt(i) ^ xor);
x += 8;
}
- if (l < string.length())
- {
+ if (l < string.length()) {
l++; // skip the \n
- x = margin;
+ x= margin;
y += 8;
}
}
@@ -877,8 +810,7 @@ public final class SCR extends Globals
SCR_DrawField
==============
*/
- static void DrawField(int x, int y, int color, int width, int value)
- {
+ static void DrawField(int x, int y, int color, int width, int value) {
char ptr;
String num;
int l;
@@ -889,26 +821,25 @@ public final class SCR extends Globals
// draw number string
if (width > 5)
- width = 5;
+ width= 5;
AddDirtyPoint(x, y);
AddDirtyPoint(x + width * CHAR_WIDTH + 2, y + 23);
- num = "" + value;
- l = num.length();
+ num= "" + value;
+ l= num.length();
if (l > width)
- l = width;
+ l= width;
x += 2 + CHAR_WIDTH * (width - l);
- ptr = num.charAt(0);
+ ptr= num.charAt(0);
- for (int i = 0; i < l; i++)
- {
- ptr = num.charAt(i);
+ for (int i= 0; i < l; i++) {
+ ptr= num.charAt(i);
if (ptr == '-')
- frame = STAT_MINUS;
+ frame= STAT_MINUS;
else
- frame = ptr - '0';
+ frame= ptr - '0';
re.DrawPic(x, y, sb_nums[color][frame]);
x += CHAR_WIDTH;
@@ -922,26 +853,24 @@ public final class SCR extends Globals
Allows rendering code to cache all needed sbar graphics
===============
*/
- static void TouchPics()
- {
+ static void TouchPics() {
int i, j;
- for (i = 0; i < 2; i++)
- for (j = 0; j < 11; j++)
+ for (i= 0; i < 2; i++)
+ for (j= 0; j < 11; j++)
re.RegisterPic(sb_nums[i][j]);
- if (crosshair.value != 0.0f)
- {
+ if (crosshair.value != 0.0f) {
if (crosshair.value > 3.0f || crosshair.value < 0.0f)
- crosshair.value = 3.0f;
+ crosshair.value= 3.0f;
- crosshair_pic = "ch" + (int) crosshair.value;
- Dimension dim = new Dimension();
+ crosshair_pic= "ch" + (int) crosshair.value;
+ Dimension dim= new Dimension();
re.DrawGetPicSize(dim, crosshair_pic);
- crosshair_width = dim.width;
- crosshair_height = dim.height;
+ crosshair_width= dim.width;
+ crosshair_height= dim.height;
if (crosshair_width == 0)
- crosshair_pic = "";
+ crosshair_pic= "";
}
}
@@ -951,8 +880,7 @@ public final class SCR extends Globals
================
*/
- static void ExecuteLayoutString(String s)
- {
+ static void ExecuteLayoutString(String s) {
int x, y;
int value;
String token;
@@ -967,61 +895,52 @@ public final class SCR extends Globals
if (s == null || s.length() == 0)
return;
- x = 0;
- y = 0;
- width = 3;
+ x= 0;
+ y= 0;
+ width= 3;
- Com.ParseHelp ph = new Com.ParseHelp(s);
+ Com.ParseHelp ph= new Com.ParseHelp(s);
- while (!ph.isEof())
- {
- token = Com.Parse(ph);
- if (token.equals("xl"))
- {
- token = Com.Parse(ph);
- x = atoi(token);
+ while (!ph.isEof()) {
+ token= Com.Parse(ph);
+ if (token.equals("xl")) {
+ token= Com.Parse(ph);
+ x= atoi(token);
continue;
}
- if (token.equals("xr"))
- {
- token = Com.Parse(ph);
- x = viddef.width + atoi(token);
+ if (token.equals("xr")) {
+ token= Com.Parse(ph);
+ x= viddef.width + atoi(token);
continue;
}
- if (token.equals("xv"))
- {
- token = Com.Parse(ph);
- x = viddef.width / 2 - 160 + atoi(token);
+ if (token.equals("xv")) {
+ token= Com.Parse(ph);
+ x= viddef.width / 2 - 160 + atoi(token);
continue;
}
- if (token.equals("yt"))
- {
- token = Com.Parse(ph);
- y = atoi(token);
+ if (token.equals("yt")) {
+ token= Com.Parse(ph);
+ y= atoi(token);
continue;
}
- if (token.equals("yb"))
- {
- token = Com.Parse(ph);
- y = viddef.height + atoi(token);
+ if (token.equals("yb")) {
+ token= Com.Parse(ph);
+ y= viddef.height + atoi(token);
continue;
}
- if (token.equals("yv"))
- {
- token = Com.Parse(ph);
- y = viddef.height / 2 - 120 + atoi(token);
+ if (token.equals("yv")) {
+ token= Com.Parse(ph);
+ y= viddef.height / 2 - 120 + atoi(token);
continue;
}
- if (token.equals("pic"))
- { // draw a pic from a stat number
- token = Com.Parse(ph);
- value = cl.frame.playerstate.stats[atoi(token)];
+ if (token.equals("pic")) { // draw a pic from a stat number
+ token= Com.Parse(ph);
+ value= cl.frame.playerstate.stats[atoi(token)];
if (value >= MAX_IMAGES)
Com.Error(ERR_DROP, "Pic >= MAX_IMAGES");
- if (cl.configstrings[CS_IMAGES + value] != null)
- {
+ if (cl.configstrings[CS_IMAGES + value] != null) {
AddDirtyPoint(x, y);
AddDirtyPoint(x + 23, y + 23);
re.DrawPic(x, y, cl.configstrings[CS_IMAGES + value]);
@@ -1029,31 +948,30 @@ public final class SCR extends Globals
continue;
}
- if (token.equals("client"))
- { // draw a deathmatch client block
+ if (token.equals("client")) { // draw a deathmatch client block
int score, ping, time;
- token = Com.Parse(ph);
- x = viddef.width / 2 - 160 + atoi(token);
- token = Com.Parse(ph);
- y = viddef.height / 2 - 120 + atoi(token);
+ token= Com.Parse(ph);
+ x= viddef.width / 2 - 160 + atoi(token);
+ token= Com.Parse(ph);
+ y= viddef.height / 2 - 120 + atoi(token);
AddDirtyPoint(x, y);
AddDirtyPoint(x + 159, y + 31);
- token = Com.Parse(ph);
- value = atoi(token);
+ token= Com.Parse(ph);
+ value= atoi(token);
if (value >= MAX_CLIENTS || value < 0)
Com.Error(ERR_DROP, "client >= MAX_CLIENTS");
- ci = cl.clientinfo[value];
+ ci= cl.clientinfo[value];
- token = Com.Parse(ph);
- score = atoi(token);
+ token= Com.Parse(ph);
+ score= atoi(token);
- token = Com.Parse(ph);
- ping = atoi(token);
+ token= Com.Parse(ph);
+ ping= atoi(token);
- token = Com.Parse(ph);
- time = atoi(token);
+ token= Com.Parse(ph);
+ time= atoi(token);
Console.DrawAltString(x + 32, y, ci.name);
Console.DrawString(x + 32, y + 8, "Score: ");
@@ -1062,38 +980,37 @@ public final class SCR extends Globals
Console.DrawString(x + 32, y + 24, "Time: " + time);
if (ci.icon == null)
- ci = cl.baseclientinfo;
+ ci= cl.baseclientinfo;
re.DrawPic(x, y, ci.iconname);
continue;
}
- if (token.equals("ctf"))
- { // draw a ctf client block
+ if (token.equals("ctf")) { // draw a ctf client block
int score, ping;
- token = Com.Parse(ph);
- x = viddef.width / 2 - 160 + atoi(token);
- token = Com.Parse(ph);
- y = viddef.height / 2 - 120 + atoi(token);
+ token= Com.Parse(ph);
+ x= viddef.width / 2 - 160 + atoi(token);
+ token= Com.Parse(ph);
+ y= viddef.height / 2 - 120 + atoi(token);
AddDirtyPoint(x, y);
AddDirtyPoint(x + 159, y + 31);
- token = Com.Parse(ph);
- value = atoi(token);
+ token= Com.Parse(ph);
+ value= atoi(token);
if (value >= MAX_CLIENTS || value < 0)
Com.Error(ERR_DROP, "client >= MAX_CLIENTS");
- ci = cl.clientinfo[value];
+ ci= cl.clientinfo[value];
- token = Com.Parse(ph);
- score = atoi(token);
+ token= Com.Parse(ph);
+ score= atoi(token);
- token = Com.Parse(ph);
- ping = atoi(token);
+ token= Com.Parse(ph);
+ ping= atoi(token);
if (ping > 999)
- ping = 999;
+ ping= 999;
// sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);
- String block = Com.sprintf("%3d %3d %-12.12s", new Vargs(3).add(score).add(ping).add(ci.name));
+ String block= Com.sprintf("%3d %3d %-12.12s", new Vargs(3).add(score).add(ping).add(ci.name));
if (value == cl.playernum)
Console.DrawAltString(x, y, block);
@@ -1102,37 +1019,34 @@ public final class SCR extends Globals
continue;
}
- if (token.equals("picn"))
- { // draw a pic from a name
- token = Com.Parse(ph);
+ if (token.equals("picn")) { // draw a pic from a name
+ token= Com.Parse(ph);
AddDirtyPoint(x, y);
AddDirtyPoint(x + 23, y + 23);
re.DrawPic(x, y, token);
continue;
}
- if (token.equals("num"))
- { // draw a number
- token = Com.Parse(ph);
- width = atoi(token);
- token = Com.Parse(ph);
- value = cl.frame.playerstate.stats[atoi(token)];
+ if (token.equals("num")) { // draw a number
+ token= Com.Parse(ph);
+ width= atoi(token);
+ token= Com.Parse(ph);
+ value= cl.frame.playerstate.stats[atoi(token)];
DrawField(x, y, 0, width, value);
continue;
}
- if (token.equals("hnum"))
- { // health number
+ if (token.equals("hnum")) { // health number
int color;
- width = 3;
- value = cl.frame.playerstate.stats[STAT_HEALTH];
+ width= 3;
+ value= cl.frame.playerstate.stats[STAT_HEALTH];
if (value > 25)
- color = 0; // green
+ color= 0; // green
else if (value > 0)
- color = (cl.frame.serverframe >> 2) & 1; // flash
+ color= (cl.frame.serverframe >> 2) & 1; // flash
else
- color = 1;
+ color= 1;
if ((cl.frame.playerstate.stats[STAT_FLASHES] & 1) != 0)
re.DrawPic(x, y, "field_3");
@@ -1141,16 +1055,15 @@ public final class SCR extends Globals
continue;
}
- if (token.equals("anum"))
- { // ammo number
+ if (token.equals("anum")) { // ammo number
int color;
- width = 3;
- value = cl.frame.playerstate.stats[STAT_AMMO];
+ width= 3;
+ value= cl.frame.playerstate.stats[STAT_AMMO];
if (value > 5)
- color = 0; // green
+ color= 0; // green
else if (value >= 0)
- color = (cl.frame.serverframe >> 2) & 1; // flash
+ color= (cl.frame.serverframe >> 2) & 1; // flash
else
continue; // negative number = don't show
@@ -1161,16 +1074,15 @@ public final class SCR extends Globals
continue;
}
- if (token.equals("rnum"))
- { // armor number
+ if (token.equals("rnum")) { // armor number
int color;
- width = 3;
- value = cl.frame.playerstate.stats[STAT_ARMOR];
+ width= 3;
+ value= cl.frame.playerstate.stats[STAT_ARMOR];
if (value < 1)
continue;
- color = 0; // green
+ color= 0; // green
if ((cl.frame.playerstate.stats[STAT_FLASHES] & 2) != 0)
re.DrawPic(x, y, "field_3");
@@ -1179,59 +1091,52 @@ public final class SCR extends Globals
continue;
}
- if (token.equals("stat_string"))
- {
- token = Com.Parse(ph);
- index = atoi(token);
+ if (token.equals("stat_string")) {
+ token= Com.Parse(ph);
+ index= atoi(token);
if (index < 0 || index >= MAX_CONFIGSTRINGS)
Com.Error(ERR_DROP, "Bad stat_string index");
- index = cl.frame.playerstate.stats[index];
+ index= cl.frame.playerstate.stats[index];
if (index < 0 || index >= MAX_CONFIGSTRINGS)
Com.Error(ERR_DROP, "Bad stat_string index");
Console.DrawString(x, y, cl.configstrings[index]);
continue;
}
- if (token.equals("cstring"))
- {
- token = Com.Parse(ph);
+ if (token.equals("cstring")) {
+ token= Com.Parse(ph);
DrawHUDString(token, x, y, 320, 0);
continue;
}
- if (token.equals("string"))
- {
- token = Com.Parse(ph);
+ if (token.equals("string")) {
+ token= Com.Parse(ph);
Console.DrawString(x, y, token);
continue;
}
- if (token.equals("cstring2"))
- {
- token = Com.Parse(ph);
+ if (token.equals("cstring2")) {
+ token= Com.Parse(ph);
DrawHUDString(token, x, y, 320, 0x80);
continue;
}
- if (token.equals("string2"))
- {
- token = Com.Parse(ph);
+ if (token.equals("string2")) {
+ token= Com.Parse(ph);
Console.DrawAltString(x, y, token);
continue;
}
- if (token.equals("if"))
- { // draw a number
- token = Com.Parse(ph);
- value = cl.frame.playerstate.stats[atoi(token)];
- if (value == 0)
- { // skip to endif
+ if (token.equals("if")) { // draw a number
+ token= Com.Parse(ph);
+ value= cl.frame.playerstate.stats[atoi(token)];
+ if (value == 0) { // skip to endif
// while (s && strcmp(token, "endif") )
// {
// token = Com.Parse(ph);
// }
- while (!ph.isEof() && !(token = Com.Parse(ph)).equals("endif"));
+ while (!ph.isEof() && !(token= Com.Parse(ph)).equals("endif"));
}
@@ -1249,8 +1154,7 @@ public final class SCR extends Globals
is based on the stats array
================
*/
- static void DrawStats()
- {
+ static void DrawStats() {
//TODO:
SCR.ExecuteLayoutString(cl.configstrings[CS_STATUSBAR]);
}
@@ -1261,10 +1165,9 @@ public final class SCR extends Globals
================
*/
- static final int STAT_LAYOUTS = 13;
+ static final int STAT_LAYOUTS= 13;
- static void DrawLayout()
- {
+ static void DrawLayout() {
if (cl.frame.playerstate.stats[STAT_LAYOUTS] != 0)
return;
SCR.ExecuteLayoutString(cl.layout);
@@ -1280,19 +1183,16 @@ public final class SCR extends Globals
text to the screen.
==================
*/
- static void UpdateScreen2()
- {
+ static void UpdateScreen2() {
int numframes;
int i;
- float[] separation = { 0, 0 };
+ float[] separation= { 0, 0 };
// if the screen is disabled (loading plaque is up, or vid mode changing)
// do nothing at all
- if (cls.disable_screen != 0)
- {
- if (Sys.Milliseconds() - cls.disable_screen > 120000)
- {
- cls.disable_screen = 0;
+ if (cls.disable_screen != 0) {
+ if (Sys.Milliseconds() - cls.disable_screen > 120000) {
+ cls.disable_screen= 0;
Com.Printf("Loading plaque timed out.\n");
}
return;
@@ -1310,67 +1210,55 @@ public final class SCR extends Globals
else if (cl_stereo_separation.value < 0)
Cvar.SetValue("cl_stereo_separation", 0.0f);
- if (cl_stereo.value != 0)
- {
- numframes = 2;
- separation[0] = -cl_stereo_separation.value / 2;
- separation[1] = cl_stereo_separation.value / 2;
+ if (cl_stereo.value != 0) {
+ numframes= 2;
+ separation[0]= -cl_stereo_separation.value / 2;
+ separation[1]= cl_stereo_separation.value / 2;
}
- else
- {
- separation[0] = 0;
- separation[1] = 0;
- numframes = 1;
+ else {
+ separation[0]= 0;
+ separation[1]= 0;
+ numframes= 1;
}
- for (i = 0; i < numframes; i++)
- {
+ for (i= 0; i < numframes; i++) {
re.BeginFrame(separation[i]);
- if (scr_draw_loading == 2)
- { // loading plaque over black screen
- Dimension dim = new Dimension();
+ if (scr_draw_loading == 2) { // loading plaque over black screen
+ Dimension dim= new Dimension();
re.CinematicSetPalette(null);
- scr_draw_loading = 0; // false
+ scr_draw_loading= 0; // false
re.DrawGetPicSize(dim, "loading");
re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading");
}
// if a cinematic is supposed to be running, handle menus
// and console specially
- else if (cl.cinematictime > 0)
- {
- if (cls.key_dest == key_menu)
- {
- if (cl.cinematicpalette_active)
- {
+ else if (cl.cinematictime > 0) {
+ if (cls.key_dest == key_menu) {
+ if (cl.cinematicpalette_active) {
re.CinematicSetPalette(null);
- cl.cinematicpalette_active = false;
+ cl.cinematicpalette_active= false;
}
Menu.Draw();
}
- else if (cls.key_dest == key_console)
- {
- if (cl.cinematicpalette_active)
- {
+ else if (cls.key_dest == key_console) {
+ if (cl.cinematicpalette_active) {
re.CinematicSetPalette(null);
- cl.cinematicpalette_active = false;
+ cl.cinematicpalette_active= false;
}
DrawConsole();
}
- else
- {
+ else {
// TODO impl: cl_cin.c for cinematics
DrawCinematic();
}
}
- else
- {
+ else {
// make sure the game palette is active
- if (cl.cinematicpalette_active)
- {
+ if (cl.cinematicpalette_active) {
re.CinematicSetPalette(null);
- cl.cinematicpalette_active = false;
+ cl.cinematicpalette_active= false;
}
// do 3D refresh drawing, and then update the screen
@@ -1382,7 +1270,7 @@ public final class SCR extends Globals
V.RenderView(separation[i]);
DrawStats();
- // TODO impl this
+
if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 1) != 0)
DrawLayout();
if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 2) != 0)
@@ -1414,14 +1302,12 @@ public final class SCR extends Globals
SCR_DrawCrosshair
=================
*/
- static void DrawCrosshair()
- {
+ static void DrawCrosshair() {
if (crosshair.value == 0.0f)
return;
- if (crosshair.modified)
- {
- crosshair.modified = false;
+ if (crosshair.modified) {
+ crosshair.modified= false;
SCR.TouchPics();
}
@@ -1434,15 +1320,14 @@ public final class SCR extends Globals
crosshair_pic);
}
- private static xcommand_t updateScreenCallback = new xcommand_t() {
+ private static xcommand_t updateScreenCallback= new xcommand_t() {
public void execute() {
UpdateScreen2();
}
- };
+ };
// wird anstelle von der richtigen UpdateScreen benoetigt
- public static void UpdateScreen()
- {
+ public static void UpdateScreen() {
Globals.re.updateScreen(updateScreenCallback);
}
@@ -1451,53 +1336,49 @@ public final class SCR extends Globals
SCR_AddDirtyPoint
=================
*/
- static void AddDirtyPoint(int x, int y)
- {
+ static void AddDirtyPoint(int x, int y) {
if (x < scr_dirty.x1)
- scr_dirty.x1 = x;
+ scr_dirty.x1= x;
if (x > scr_dirty.x2)
- scr_dirty.x2 = x;
+ scr_dirty.x2= x;
if (y < scr_dirty.y1)
- scr_dirty.y1 = y;
+ scr_dirty.y1= y;
if (y > scr_dirty.y2)
- scr_dirty.y2 = y;
+ scr_dirty.y2= y;
}
- private static int lastframes = 0;
- private static int lasttime = 0;
- private static String fpsvalue = "";
-
- static void DrawFPS()
- {
- if (fps.value > 0.0f)
- {
+ private static int lastframes= 0;
+ private static int lasttime= 0;
+ private static String fpsvalue= "";
+
+ static void DrawFPS() {
+ if (fps.value > 0.0f) {
if (fps.modified) {
- fps.modified = false;
+ fps.modified= false;
Cvar.SetValue("cl_maxfps", 1000);
}
-
- int diff = cls.realtime - lasttime;
- if (diff > (int) (fps.value * 1000))
- {
- fpsvalue = (cls.framecount - lastframes) * 100000 / diff / 100.0f + " fps";
- lastframes = cls.framecount;
- lasttime = cls.realtime;
+
+ int diff= cls.realtime - lasttime;
+ if (diff > (int) (fps.value * 1000)) {
+ fpsvalue= (cls.framecount - lastframes) * 100000 / diff / 100.0f + " fps";
+ lastframes= cls.framecount;
+ lasttime= cls.realtime;
}
- int x = viddef.width - 8 * fpsvalue.length() - 2;
- for (int i = 0; i < fpsvalue.length(); i++)
- {
+ int x= viddef.width - 8 * fpsvalue.length() - 2;
+ for (int i= 0; i < fpsvalue.length(); i++) {
re.DrawChar(x, 2, fpsvalue.charAt(i));
x += 8;
}
- } else if (fps.modified){
- fps.modified = false;
- Cvar.SetValue("cl_maxfps", 90);
+ }
+ else if (fps.modified) {
+ fps.modified= false;
+ Cvar.SetValue("cl_maxfps", 90);
}
}
-
+
/*
=================================================================
-
+
cl_cin.c
Play Cinematics
@@ -1505,130 +1386,130 @@ public final class SCR extends Globals
=================================================================
*/
-// typedef struct
-// {
-// byte *data;
-// int count;
-// } cblock_t;
-//
-// typedef struct
-// {
-// qboolean restart_sound;
-// int s_rate;
-// int s_width;
-// int s_channels;
-//
-// int width;
-// int height;
-// byte *pic;
-// byte *pic_pending;
-//
-// // order 1 huffman stuff
-// int *hnodes1; // [256][256][2];
-// int numhnodes1[256];
-//
-// int h_used[512];
-// int h_count[512];
-// } cinematics_t;
-//
-// cinematics_t cin;
-//
-// /*
-// =================================================================
-//
-// PCX LOADING
-//
-// =================================================================
-// */
-//
-//
-// /*
-// ==============
-// SCR_LoadPCX
-// ==============
-// */
-// void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
-// {
-// byte *raw;
-// pcx_t *pcx;
-// int x, y;
-// int len;
-// int dataByte, runLength;
-// byte *out, *pix;
-//
-// *pic = NULL;
-//
-// //
-// // load the file
-// //
-// len = FS_LoadFile (filename, (void **)&raw);
-// if (!raw)
-// return; // Com_Printf ("Bad pcx file %s\n", filename);
-//
-// //
-// // parse the PCX file
-// //
-// pcx = (pcx_t *)raw;
-// raw = &pcx->data;
-//
-// if (pcx->manufacturer != 0x0a
-// || pcx->version != 5
-// || pcx->encoding != 1
-// || pcx->bits_per_pixel != 8
-// || pcx->xmax >= 640
-// || pcx->ymax >= 480)
-// {
-// Com_Printf ("Bad pcx file %s\n", filename);
-// return;
-// }
-//
-// out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
-//
-// *pic = out;
-//
-// pix = out;
-//
-// if (palette)
-// {
-// *palette = Z_Malloc(768);
-// memcpy (*palette, (byte *)pcx + len - 768, 768);
-// }
-//
-// if (width)
-// *width = pcx->xmax+1;
-// if (height)
-// *height = pcx->ymax+1;
-//
-// for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
-// {
-// for (x=0 ; x<=pcx->xmax ; )
-// {
-// dataByte = *raw++;
-//
-// if((dataByte & 0xC0) == 0xC0)
-// {
-// runLength = dataByte & 0x3F;
-// dataByte = *raw++;
-// }
-// else
-// runLength = 1;
-//
-// while(runLength-- > 0)
-// pix[x++] = dataByte;
-// }
-//
-// }
-//
-// if ( raw - (byte *)pcx > len)
-// {
-// Com_Printf ("PCX file %s was malformed", filename);
-// Z_Free (*pic);
-// *pic = NULL;
-// }
-//
-// FS_FreeFile (pcx);
-// }
-//
+ // typedef struct
+ // {
+ // byte *data;
+ // int count;
+ // } cblock_t;
+ //
+ // typedef struct
+ // {
+ // qboolean restart_sound;
+ // int s_rate;
+ // int s_width;
+ // int s_channels;
+ //
+ // int width;
+ // int height;
+ // byte *pic;
+ // byte *pic_pending;
+ //
+ // // order 1 huffman stuff
+ // int *hnodes1; // [256][256][2];
+ // int numhnodes1[256];
+ //
+ // int h_used[512];
+ // int h_count[512];
+ // } cinematics_t;
+ //
+ // cinematics_t cin;
+ //
+ // /*
+ // =================================================================
+ //
+ // PCX LOADING
+ //
+ // =================================================================
+ // */
+ //
+ //
+ // /*
+ // ==============
+ // SCR_LoadPCX
+ // ==============
+ // */
+ // void SCR_LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height)
+ // {
+ // byte *raw;
+ // pcx_t *pcx;
+ // int x, y;
+ // int len;
+ // int dataByte, runLength;
+ // byte *out, *pix;
+ //
+ // *pic = NULL;
+ //
+ // //
+ // // load the file
+ // //
+ // len = FS_LoadFile (filename, (void **)&raw);
+ // if (!raw)
+ // return; // Com_Printf ("Bad pcx file %s\n", filename);
+ //
+ // //
+ // // parse the PCX file
+ // //
+ // pcx = (pcx_t *)raw;
+ // raw = &pcx->data;
+ //
+ // if (pcx->manufacturer != 0x0a
+ // || pcx->version != 5
+ // || pcx->encoding != 1
+ // || pcx->bits_per_pixel != 8
+ // || pcx->xmax >= 640
+ // || pcx->ymax >= 480)
+ // {
+ // Com_Printf ("Bad pcx file %s\n", filename);
+ // return;
+ // }
+ //
+ // out = Z_Malloc ( (pcx->ymax+1) * (pcx->xmax+1) );
+ //
+ // *pic = out;
+ //
+ // pix = out;
+ //
+ // if (palette)
+ // {
+ // *palette = Z_Malloc(768);
+ // memcpy (*palette, (byte *)pcx + len - 768, 768);
+ // }
+ //
+ // if (width)
+ // *width = pcx->xmax+1;
+ // if (height)
+ // *height = pcx->ymax+1;
+ //
+ // for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1)
+ // {
+ // for (x=0 ; x<=pcx->xmax ; )
+ // {
+ // dataByte = *raw++;
+ //
+ // if((dataByte & 0xC0) == 0xC0)
+ // {
+ // runLength = dataByte & 0x3F;
+ // dataByte = *raw++;
+ // }
+ // else
+ // runLength = 1;
+ //
+ // while(runLength-- > 0)
+ // pix[x++] = dataByte;
+ // }
+ //
+ // }
+ //
+ // if ( raw - (byte *)pcx > len)
+ // {
+ // Com_Printf ("PCX file %s was malformed", filename);
+ // Z_Free (*pic);
+ // *pic = NULL;
+ // }
+ //
+ // FS_FreeFile (pcx);
+ // }
+ //
// =============================================================
/*
@@ -1636,53 +1517,50 @@ public final class SCR extends Globals
SCR_StopCinematic
==================
*/
- static void StopCinematic()
- {
- cl.cinematictime = 0; // done
-// if (cin.pic)
-// {
-// Z_Free (cin.pic);
-// cin.pic = NULL;
-// }
-// if (cin.pic_pending)
-// {
-// Z_Free (cin.pic_pending);
-// cin.pic_pending = NULL;
-// }
- if (cl.cinematicpalette_active)
- {
+ static void StopCinematic() {
+ cl.cinematictime= 0; // done
+ // if (cin.pic)
+ // {
+ // Z_Free (cin.pic);
+ // cin.pic = NULL;
+ // }
+ // if (cin.pic_pending)
+ // {
+ // Z_Free (cin.pic_pending);
+ // cin.pic_pending = NULL;
+ // }
+ if (cl.cinematicpalette_active) {
re.CinematicSetPalette(null);
- cl.cinematicpalette_active = false;
+ cl.cinematicpalette_active= false;
}
-// if (cl.cinematic_file)
-// {
-// fclose (cl.cinematic_file);
-// cl.cinematic_file = NULL;
-// }
-// if (cin.hnodes1)
-// {
-// Z_Free (cin.hnodes1);
-// cin.hnodes1 = NULL;
-// }
-//
-// // switch back down to 11 khz sound if necessary
-// if (cin.restart_sound)
-// {
-// cin.restart_sound = false;
-// CL_Snd_Restart_f ();
-// }
-//
+ // if (cl.cinematic_file)
+ // {
+ // fclose (cl.cinematic_file);
+ // cl.cinematic_file = NULL;
+ // }
+ // if (cin.hnodes1)
+ // {
+ // Z_Free (cin.hnodes1);
+ // cin.hnodes1 = NULL;
+ // }
+ //
+ // // switch back down to 11 khz sound if necessary
+ // if (cin.restart_sound)
+ // {
+ // cin.restart_sound = false;
+ // CL_Snd_Restart_f ();
+ // }
+ //
}
/*
====================
SCR_FinishCinematic
-
+
Called when either the cinematic completes, or it is aborted
====================
*/
- static void FinishCinematic()
- {
+ static void FinishCinematic() {
// tell the server to advance to the next map / cinematic
MSG.WriteByte(cls.netchan.message, clc_stringcmd);
SZ.Print(cls.netchan.message, "nextserver " + cl.servercount + '\n');
@@ -1690,449 +1568,444 @@ public final class SCR extends Globals
// ==========================================================================
-// /*
-// ==================
-// SmallestNode1
-// ==================
-// */
-// int SmallestNode1 (int numhnodes)
-// {
-// int i;
-// int best, bestnode;
-//
-// best = 99999999;
-// bestnode = -1;
-// for (i=0 ; i<numhnodes ; i++)
-// {
-// if (cin.h_used[i])
-// continue;
-// if (!cin.h_count[i])
-// continue;
-// if (cin.h_count[i] < best)
-// {
-// best = cin.h_count[i];
-// bestnode = i;
-// }
-// }
-//
-// if (bestnode == -1)
-// return -1;
-//
-// cin.h_used[bestnode] = true;
-// return bestnode;
-// }
-//
-//
-// /*
-// ==================
-// Huff1TableInit
-//
-// Reads the 64k counts table and initializes the node trees
-// ==================
-// */
-// void Huff1TableInit (void)
-// {
-// int prev;
-// int j;
-// int *node, *nodebase;
-// byte counts[256];
-// int numhnodes;
-//
-// cin.hnodes1 = Z_Malloc (256*256*2*4);
-// memset (cin.hnodes1, 0, 256*256*2*4);
-//
-// for (prev=0 ; prev<256 ; prev++)
-// {
-// memset (cin.h_count,0,sizeof(cin.h_count));
-// memset (cin.h_used,0,sizeof(cin.h_used));
-//
-// // read a row of counts
-// FS_Read (counts, sizeof(counts), cl.cinematic_file);
-// for (j=0 ; j<256 ; j++)
-// cin.h_count[j] = counts[j];
-//
-// // build the nodes
-// numhnodes = 256;
-// nodebase = cin.hnodes1 + prev*256*2;
-//
-// while (numhnodes != 511)
-// {
-// node = nodebase + (numhnodes-256)*2;
-//
-// // pick two lowest counts
-// node[0] = SmallestNode1 (numhnodes);
-// if (node[0] == -1)
-// break; // no more
-//
-// node[1] = SmallestNode1 (numhnodes);
-// if (node[1] == -1)
-// break;
-//
-// cin.h_count[numhnodes] = cin.h_count[node[0]] + cin.h_count[node[1]];
-// numhnodes++;
-// }
-//
-// cin.numhnodes1[prev] = numhnodes-1;
-// }
-// }
-//
-// /*
-// ==================
-// Huff1Decompress
-// ==================
-// */
-// cblock_t Huff1Decompress (cblock_t in)
-// {
-// byte *input;
-// byte *out_p;
-// int nodenum;
-// int count;
-// cblock_t out;
-// int inbyte;
-// int *hnodes, *hnodesbase;
-//// int i;
-//
-// // get decompressed count
-// count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + (in.data[3]<<24);
-// input = in.data + 4;
-// out_p = out.data = Z_Malloc (count);
-//
-// // read bits
-//
-// hnodesbase = cin.hnodes1 - 256*2; // nodes 0-255 aren't stored
-//
-// hnodes = hnodesbase;
-// nodenum = cin.numhnodes1[0];
-// while (count)
-// {
-// inbyte = *input++;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// //-----------
-// if (nodenum < 256)
-// {
-// hnodes = hnodesbase + (nodenum<<9);
-// *out_p++ = nodenum;
-// if (!--count)
-// break;
-// nodenum = cin.numhnodes1[nodenum];
-// }
-// nodenum = hnodes[nodenum*2 + (inbyte&1)];
-// inbyte >>=1;
-// }
-//
-// if (input - in.data != in.count && input - in.data != in.count+1)
-// {
-// Com_Printf ("Decompression overread by %i", (input - in.data) - in.count);
-// }
-// out.count = out_p - out.data;
-//
-// return out;
-// }
-//
-// /*
-// ==================
-// SCR_ReadNextFrame
-// ==================
-// */
-// byte *SCR_ReadNextFrame (void)
-// {
-// int r;
-// int command;
-// byte samples[22050/14*4];
-// byte compressed[0x20000];
-// int size;
-// byte *pic;
-// cblock_t in, huf1;
-// int start, end, count;
-//
-// // read the next frame
-// r = fread (&command, 4, 1, cl.cinematic_file);
-// if (r == 0) // we'll give it one more chance
-// r = fread (&command, 4, 1, cl.cinematic_file);
-//
-// if (r != 1)
-// return NULL;
-// command = LittleLong(command);
-// if (command == 2)
-// return NULL; // last frame marker
-//
-// if (command == 1)
-// { // read palette
-// FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette), cl.cinematic_file);
-// cl.cinematicpalette_active=0; // dubious.... exposes an edge case
-// }
-//
-// // decompress the next frame
-// FS_Read (&size, 4, cl.cinematic_file);
-// size = LittleLong(size);
-// if (size > sizeof(compressed) || size < 1)
-// Com_Error (ERR_DROP, "Bad compressed frame size");
-// FS_Read (compressed, size, cl.cinematic_file);
-//
-// // read sound
-// start = cl.cinematicframe*cin.s_rate/14;
-// end = (cl.cinematicframe+1)*cin.s_rate/14;
-// count = end - start;
-//
-// FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file);
-//
-// S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples);
-//
-// in.data = compressed;
-// in.count = size;
-//
-// huf1 = Huff1Decompress (in);
-//
-// pic = huf1.data;
-//
-// cl.cinematicframe++;
-//
-// return pic;
-// }
-//
-//
+ // /*
+ // ==================
+ // SmallestNode1
+ // ==================
+ // */
+ // int SmallestNode1 (int numhnodes)
+ // {
+ // int i;
+ // int best, bestnode;
+ //
+ // best = 99999999;
+ // bestnode = -1;
+ // for (i=0 ; i<numhnodes ; i++)
+ // {
+ // if (cin.h_used[i])
+ // continue;
+ // if (!cin.h_count[i])
+ // continue;
+ // if (cin.h_count[i] < best)
+ // {
+ // best = cin.h_count[i];
+ // bestnode = i;
+ // }
+ // }
+ //
+ // if (bestnode == -1)
+ // return -1;
+ //
+ // cin.h_used[bestnode] = true;
+ // return bestnode;
+ // }
+ //
+ //
+ // /*
+ // ==================
+ // Huff1TableInit
+ //
+ // Reads the 64k counts table and initializes the node trees
+ // ==================
+ // */
+ // void Huff1TableInit (void)
+ // {
+ // int prev;
+ // int j;
+ // int *node, *nodebase;
+ // byte counts[256];
+ // int numhnodes;
+ //
+ // cin.hnodes1 = Z_Malloc (256*256*2*4);
+ // memset (cin.hnodes1, 0, 256*256*2*4);
+ //
+ // for (prev=0 ; prev<256 ; prev++)
+ // {
+ // memset (cin.h_count,0,sizeof(cin.h_count));
+ // memset (cin.h_used,0,sizeof(cin.h_used));
+ //
+ // // read a row of counts
+ // FS_Read (counts, sizeof(counts), cl.cinematic_file);
+ // for (j=0 ; j<256 ; j++)
+ // cin.h_count[j] = counts[j];
+ //
+ // // build the nodes
+ // numhnodes = 256;
+ // nodebase = cin.hnodes1 + prev*256*2;
+ //
+ // while (numhnodes != 511)
+ // {
+ // node = nodebase + (numhnodes-256)*2;
+ //
+ // // pick two lowest counts
+ // node[0] = SmallestNode1 (numhnodes);
+ // if (node[0] == -1)
+ // break; // no more
+ //
+ // node[1] = SmallestNode1 (numhnodes);
+ // if (node[1] == -1)
+ // break;
+ //
+ // cin.h_count[numhnodes] = cin.h_count[node[0]] + cin.h_count[node[1]];
+ // numhnodes++;
+ // }
+ //
+ // cin.numhnodes1[prev] = numhnodes-1;
+ // }
+ // }
+ //
+ // /*
+ // ==================
+ // Huff1Decompress
+ // ==================
+ // */
+ // cblock_t Huff1Decompress (cblock_t in)
+ // {
+ // byte *input;
+ // byte *out_p;
+ // int nodenum;
+ // int count;
+ // cblock_t out;
+ // int inbyte;
+ // int *hnodes, *hnodesbase;
+ //// int i;
+ //
+ // // get decompressed count
+ // count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + (in.data[3]<<24);
+ // input = in.data + 4;
+ // out_p = out.data = Z_Malloc (count);
+ //
+ // // read bits
+ //
+ // hnodesbase = cin.hnodes1 - 256*2; // nodes 0-255 aren't stored
+ //
+ // hnodes = hnodesbase;
+ // nodenum = cin.numhnodes1[0];
+ // while (count)
+ // {
+ // inbyte = *input++;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // //-----------
+ // if (nodenum < 256)
+ // {
+ // hnodes = hnodesbase + (nodenum<<9);
+ // *out_p++ = nodenum;
+ // if (!--count)
+ // break;
+ // nodenum = cin.numhnodes1[nodenum];
+ // }
+ // nodenum = hnodes[nodenum*2 + (inbyte&1)];
+ // inbyte >>=1;
+ // }
+ //
+ // if (input - in.data != in.count && input - in.data != in.count+1)
+ // {
+ // Com_Printf ("Decompression overread by %i", (input - in.data) - in.count);
+ // }
+ // out.count = out_p - out.data;
+ //
+ // return out;
+ // }
+ //
+ // /*
+ // ==================
+ // SCR_ReadNextFrame
+ // ==================
+ // */
+ // byte *SCR_ReadNextFrame (void)
+ // {
+ // int r;
+ // int command;
+ // byte samples[22050/14*4];
+ // byte compressed[0x20000];
+ // int size;
+ // byte *pic;
+ // cblock_t in, huf1;
+ // int start, end, count;
+ //
+ // // read the next frame
+ // r = fread (&command, 4, 1, cl.cinematic_file);
+ // if (r == 0) // we'll give it one more chance
+ // r = fread (&command, 4, 1, cl.cinematic_file);
+ //
+ // if (r != 1)
+ // return NULL;
+ // command = LittleLong(command);
+ // if (command == 2)
+ // return NULL; // last frame marker
+ //
+ // if (command == 1)
+ // { // read palette
+ // FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette), cl.cinematic_file);
+ // cl.cinematicpalette_active=0; // dubious.... exposes an edge case
+ // }
+ //
+ // // decompress the next frame
+ // FS_Read (&size, 4, cl.cinematic_file);
+ // size = LittleLong(size);
+ // if (size > sizeof(compressed) || size < 1)
+ // Com_Error (ERR_DROP, "Bad compressed frame size");
+ // FS_Read (compressed, size, cl.cinematic_file);
+ //
+ // // read sound
+ // start = cl.cinematicframe*cin.s_rate/14;
+ // end = (cl.cinematicframe+1)*cin.s_rate/14;
+ // count = end - start;
+ //
+ // FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file);
+ //
+ // S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples);
+ //
+ // in.data = compressed;
+ // in.count = size;
+ //
+ // huf1 = Huff1Decompress (in);
+ //
+ // pic = huf1.data;
+ //
+ // cl.cinematicframe++;
+ //
+ // return pic;
+ // }
+ //
+ //
/*
==================
SCR_RunCinematic
-
+
==================
*/
- static void RunCinematic()
- {
- int frame;
+ static void RunCinematic() {
+ int frame;
- if (cl.cinematictime <= 0)
- {
+ if (cl.cinematictime <= 0) {
StopCinematic();
return;
}
-// if (cl.cinematicframe == -1)
-// return; // static image
-//
-// if (cls.key_dest != key_game)
-// { // pause if menu or console is up
-// cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
-// return;
-// }
-//
-// frame = (cls.realtime - cl.cinematictime)*14.0/1000;
-// if (frame <= cl.cinematicframe)
-// return;
-// if (frame > cl.cinematicframe+1)
-// {
-// Com_Printf ("Dropped frame: %i > %i\n", frame, cl.cinematicframe+1);
-// cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
-// }
-// if (cin.pic)
-// Z_Free (cin.pic);
-// cin.pic = cin.pic_pending;
-// cin.pic_pending = NULL;
-// cin.pic_pending = SCR_ReadNextFrame ();
-// if (!cin.pic_pending)
-// {
-// SCR_StopCinematic ();
-// SCR_FinishCinematic ();
-// cl.cinematictime = 1; // hack to get the black screen behind loading
-// SCR_BeginLoadingPlaque ();
-// cl.cinematictime = 0;
-// return;
-// }
+ // if (cl.cinematicframe == -1)
+ // return; // static image
+ //
+ // if (cls.key_dest != key_game)
+ // { // pause if menu or console is up
+ // cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
+ // return;
+ // }
+ //
+ // frame = (cls.realtime - cl.cinematictime)*14.0/1000;
+ // if (frame <= cl.cinematicframe)
+ // return;
+ // if (frame > cl.cinematicframe+1)
+ // {
+ // Com_Printf ("Dropped frame: %i > %i\n", frame, cl.cinematicframe+1);
+ // cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
+ // }
+ // if (cin.pic)
+ // Z_Free (cin.pic);
+ // cin.pic = cin.pic_pending;
+ // cin.pic_pending = NULL;
+ // cin.pic_pending = SCR_ReadNextFrame ();
+ // if (!cin.pic_pending)
+ // {
+ // SCR_StopCinematic ();
+ // SCR_FinishCinematic ();
+ // cl.cinematictime = 1; // hack to get the black screen behind loading
+ // SCR_BeginLoadingPlaque ();
+ // cl.cinematictime = 0;
+ // return;
+ // }
}
/*
==================
SCR_DrawCinematic
-
+
Returns true if a cinematic is active, meaning the view rendering
should be skipped
==================
*/
- static boolean DrawCinematic()
- {
-// if (cl.cinematictime <= 0)
-// {
- return false;
-// }
-//
-// if (cls.key_dest == key_menu)
-// { // blank screen and pause if menu is up
-// re.CinematicSetPalette(NULL);
-// cl.cinematicpalette_active = false;
-// return true;
-// }
-//
-// if (!cl.cinematicpalette_active)
-// {
-// re.CinematicSetPalette(cl.cinematicpalette);
-// cl.cinematicpalette_active = true;
-// }
-//
-// if (!cin.pic)
-// return true;
-//
-// re.DrawStretchRaw (0, 0, viddef.width, viddef.height,
-// cin.width, cin.height, cin.pic);
-//
-// return true;
+ static boolean DrawCinematic() {
+ // if (cl.cinematictime <= 0)
+ // {
+ return false;
+ // }
+ //
+ // if (cls.key_dest == key_menu)
+ // { // blank screen and pause if menu is up
+ // re.CinematicSetPalette(NULL);
+ // cl.cinematicpalette_active = false;
+ // return true;
+ // }
+ //
+ // if (!cl.cinematicpalette_active)
+ // {
+ // re.CinematicSetPalette(cl.cinematicpalette);
+ // cl.cinematicpalette_active = true;
+ // }
+ //
+ // if (!cin.pic)
+ // return true;
+ //
+ // re.DrawStretchRaw (0, 0, viddef.width, viddef.height,
+ // cin.width, cin.height, cin.pic);
+ //
+ // return true;
}
/*
==================
SCR_PlayCinematic
-
+
==================
*/
- static void PlayCinematic(String arg)
- {
-// int width, height;
-// byte *palette;
-// char name[MAX_OSPATH], *dot;
-// int old_khz;
-//
-// // make sure CD isn't playing music
+ static void PlayCinematic(String arg) {
+ // int width, height;
+ // byte *palette;
+ // char name[MAX_OSPATH], *dot;
+ // int old_khz;
+ //
+ // // make sure CD isn't playing music
//CDAudio.Stop();
- cl.cinematicframe = 0;
-// dot = strstr (arg, ".");
-// if (dot && !strcmp (dot, ".pcx"))
-// { // static pcx image
-// Com_sprintf (name, sizeof(name), "pics/%s", arg);
-// SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height);
-// cl.cinematicframe = -1;
-// cl.cinematictime = 1;
-// SCR_EndLoadingPlaque ();
-// cls.state = ca_active;
-// if (!cin.pic)
-// {
-// Com_Printf ("%s not found.\n", name);
-// cl.cinematictime = 0;
-// }
-// else
-// {
-// memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
-// Z_Free (palette);
-// }
-// return;
-// }
-//
-// Com_sprintf (name, sizeof(name), "video/%s", arg);
-// FS_FOpenFile (name, &cl.cinematic_file);
-// if (!cl.cinematic_file)
-// {
- // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name);
- FinishCinematic();
- cl.cinematictime = 0; // done
- return;
-// }
-//
-// SCR_EndLoadingPlaque ();
-//
-// cls.state = ca_active;
-//
-// FS_Read (&width, 4, cl.cinematic_file);
-// FS_Read (&height, 4, cl.cinematic_file);
-// cin.width = LittleLong(width);
-// cin.height = LittleLong(height);
-//
-// FS_Read (&cin.s_rate, 4, cl.cinematic_file);
-// cin.s_rate = LittleLong(cin.s_rate);
-// FS_Read (&cin.s_width, 4, cl.cinematic_file);
-// cin.s_width = LittleLong(cin.s_width);
-// FS_Read (&cin.s_channels, 4, cl.cinematic_file);
-// cin.s_channels = LittleLong(cin.s_channels);
-//
-// Huff1TableInit ();
-//
-// // switch up to 22 khz sound if necessary
-// old_khz = Cvar_VariableValue ("s_khz");
-// if (old_khz != cin.s_rate/1000)
-// {
-// cin.restart_sound = true;
-// Cvar_SetValue ("s_khz", cin.s_rate/1000);
-// CL_Snd_Restart_f ();
-// Cvar_SetValue ("s_khz", old_khz);
-// }
-//
-// cl.cinematicframe = 0;
-// cin.pic = SCR_ReadNextFrame ();
-// cl.cinematictime = Sys_Milliseconds ();
+ cl.cinematicframe= 0;
+ // dot = strstr (arg, ".");
+ // if (dot && !strcmp (dot, ".pcx"))
+ // { // static pcx image
+ // Com_sprintf (name, sizeof(name), "pics/%s", arg);
+ // SCR_LoadPCX (name, &cin.pic, &palette, &cin.width, &cin.height);
+ // cl.cinematicframe = -1;
+ // cl.cinematictime = 1;
+ // SCR_EndLoadingPlaque ();
+ // cls.state = ca_active;
+ // if (!cin.pic)
+ // {
+ // Com_Printf ("%s not found.\n", name);
+ // cl.cinematictime = 0;
+ // }
+ // else
+ // {
+ // memcpy (cl.cinematicpalette, palette, sizeof(cl.cinematicpalette));
+ // Z_Free (palette);
+ // }
+ // return;
+ // }
+ //
+ // Com_sprintf (name, sizeof(name), "video/%s", arg);
+ // FS_FOpenFile (name, &cl.cinematic_file);
+ // if (!cl.cinematic_file)
+ // {
+ // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name);
+ FinishCinematic();
+ cl.cinematictime= 0; // done
+ return;
+ // }
+ //
+ // SCR_EndLoadingPlaque ();
+ //
+ // cls.state = ca_active;
+ //
+ // FS_Read (&width, 4, cl.cinematic_file);
+ // FS_Read (&height, 4, cl.cinematic_file);
+ // cin.width = LittleLong(width);
+ // cin.height = LittleLong(height);
+ //
+ // FS_Read (&cin.s_rate, 4, cl.cinematic_file);
+ // cin.s_rate = LittleLong(cin.s_rate);
+ // FS_Read (&cin.s_width, 4, cl.cinematic_file);
+ // cin.s_width = LittleLong(cin.s_width);
+ // FS_Read (&cin.s_channels, 4, cl.cinematic_file);
+ // cin.s_channels = LittleLong(cin.s_channels);
+ //
+ // Huff1TableInit ();
+ //
+ // // switch up to 22 khz sound if necessary
+ // old_khz = Cvar_VariableValue ("s_khz");
+ // if (old_khz != cin.s_rate/1000)
+ // {
+ // cin.restart_sound = true;
+ // Cvar_SetValue ("s_khz", cin.s_rate/1000);
+ // CL_Snd_Restart_f ();
+ // Cvar_SetValue ("s_khz", old_khz);
+ // }
+ //
+ // cl.cinematicframe = 0;
+ // cin.pic = SCR_ReadNextFrame ();
+ // cl.cinematictime = Sys_Milliseconds ();
}
-
} \ No newline at end of file
diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java
index db2b3f0..cdec20b 100644
--- a/src/jake2/game/GameBase.java
+++ b/src/jake2/game/GameBase.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 30.11.2003 by RST.
-// $Id: GameBase.java,v 1.4 2004-08-20 21:29:58 salomo Exp $
+// $Id: GameBase.java,v 1.5 2004-08-22 14:25:11 salomo Exp $
/** Father of all GameObjects. */
@@ -33,181 +33,88 @@ import jake2.qcommon.Com;
import jake2.server.*;
import jake2.util.*;
-public class GameBase extends Globals
-{
- public static cplane_t dummyplane = new cplane_t();
- public static game_locals_t game = new game_locals_t();
- public static level_locals_t level = new level_locals_t();
- public static game_import_t gi = new game_import_t();
- public static game_export_t globals = new game_export_t();
- public static spawn_temp_t st = new spawn_temp_t();
+public class GameBase extends Globals {
+ public static cplane_t dummyplane= new cplane_t();
+ public static game_locals_t game= new game_locals_t();
+ public static level_locals_t level= new level_locals_t();
+ public static game_import_t gi= new game_import_t();
+ public static game_export_t globals= new game_export_t();
+ public static spawn_temp_t st= new spawn_temp_t();
public static int sm_meat_index;
public static int snd_fry;
public static int meansOfDeath;
- public static edict_t g_edicts[] = new edict_t[MAX_EDICTS];
+ public static edict_t g_edicts[]= new edict_t[MAX_EDICTS];
static {
- for (int n = 0; n < MAX_EDICTS; n++)
- g_edicts[n] = new edict_t(n);
+ for (int n= 0; n < MAX_EDICTS; n++)
+ g_edicts[n]= new edict_t(n);
}
- public static cvar_t deathmatch = new cvar_t();
- public static cvar_t coop = new cvar_t();
- public static cvar_t dmflags = new cvar_t();
+ public static cvar_t deathmatch= new cvar_t();
+ public static cvar_t coop= new cvar_t();
+ public static cvar_t dmflags= new cvar_t();
public static cvar_t skill; // = new cvar_t();
- public static cvar_t fraglimit = new cvar_t();
- public static cvar_t timelimit = new cvar_t();
- public static cvar_t password = new cvar_t();
- public static cvar_t spectator_password = new cvar_t();
- public static cvar_t needpass = new cvar_t();
- public static cvar_t maxclients = new cvar_t();
- public static cvar_t maxspectators = new cvar_t();
- public static cvar_t maxentities = new cvar_t();
- public static cvar_t g_select_empty = new cvar_t();
- public static cvar_t dedicated = new cvar_t();
-
- public static cvar_t filterban = new cvar_t();
-
- public static cvar_t sv_maxvelocity = new cvar_t();
- public static cvar_t sv_gravity = new cvar_t();
-
- public static cvar_t sv_rollspeed = new cvar_t();
- public static cvar_t sv_rollangle = new cvar_t();
- public static cvar_t gun_x = new cvar_t();
- public static cvar_t gun_y = new cvar_t();
- public static cvar_t gun_z = new cvar_t();
-
- public static cvar_t run_pitch = new cvar_t();
- public static cvar_t run_roll = new cvar_t();
- public static cvar_t bob_up = new cvar_t();
- public static cvar_t bob_pitch = new cvar_t();
- public static cvar_t bob_roll = new cvar_t();
-
- public static cvar_t sv_cheats = new cvar_t();
-
- public static cvar_t flood_msgs = new cvar_t();
- public static cvar_t flood_persecond = new cvar_t();
- public static cvar_t flood_waitdelay = new cvar_t();
-
- public static cvar_t sv_maplist = new cvar_t();
-
- public final static float STOP_EPSILON = 0.1f;
-
- static field_t fields_ent[] =
- new field_t[] {
- new field_t("classname", F_LSTRING),
- new field_t("model", F_LSTRING),
- new field_t("spawnflags", F_INT),
- new field_t("speed", F_FLOAT),
- new field_t("accel", F_FLOAT),
- new field_t("decel", F_FLOAT),
- new field_t("target", F_LSTRING),
- new field_t("targetname", F_LSTRING),
- new field_t("pathtarget", F_LSTRING),
- new field_t("deathtarget", F_LSTRING),
- new field_t("killtarget", F_LSTRING),
- new field_t("combattarget", F_LSTRING),
- new field_t("message", F_LSTRING),
- new field_t("team", F_LSTRING),
- new field_t("wait", F_FLOAT),
- new field_t("delay", F_FLOAT),
- new field_t("random", F_FLOAT),
- new field_t("move_origin", F_VECTOR),
- new field_t("move_angles", F_VECTOR),
- new field_t("style", F_INT),
- new field_t("count", F_INT),
- new field_t("health", F_INT),
- new field_t("sounds", F_INT),
- new field_t("light", F_IGNORE),
- new field_t("dmg", F_INT),
- new field_t("mass", F_INT),
- new field_t("volume", F_FLOAT),
- new field_t("attenuation", F_FLOAT),
- new field_t("map", F_LSTRING),
- new field_t("origin", F_VECTOR),
- new field_t("angles", F_VECTOR),
- new field_t("angle", F_ANGLEHACK),
- new field_t("goalentity", F_EDICT, FFL_NOSPAWN),
- new field_t("movetarget", F_EDICT, FFL_NOSPAWN),
- new field_t("enemy", F_EDICT, FFL_NOSPAWN),
- new field_t("oldenemy", F_EDICT, FFL_NOSPAWN),
- new field_t("activator", F_EDICT, FFL_NOSPAWN),
- new field_t("groundentity", F_EDICT, FFL_NOSPAWN),
- new field_t("teamchain", F_EDICT, FFL_NOSPAWN),
- new field_t("teammaster", F_EDICT, FFL_NOSPAWN),
- new field_t("owner", F_EDICT, FFL_NOSPAWN),
- new field_t("mynoise", F_EDICT, FFL_NOSPAWN),
- new field_t("mynoise2", F_EDICT, FFL_NOSPAWN),
- new field_t("target_ent", F_EDICT, FFL_NOSPAWN),
- new field_t("chain", F_EDICT, FFL_NOSPAWN),
- new field_t("prethink", F_FUNCTION, FFL_NOSPAWN),
- new field_t("think", F_FUNCTION, FFL_NOSPAWN),
- new field_t("blocked", F_FUNCTION, FFL_NOSPAWN),
- new field_t("touch", F_FUNCTION, FFL_NOSPAWN),
- new field_t("use", F_FUNCTION, FFL_NOSPAWN),
- new field_t("pain", F_FUNCTION, FFL_NOSPAWN),
- new field_t("die", F_FUNCTION, FFL_NOSPAWN),
- new field_t("stand", F_FUNCTION, FFL_NOSPAWN),
- new field_t("idle", F_FUNCTION, FFL_NOSPAWN),
- new field_t("search", F_FUNCTION, FFL_NOSPAWN),
- new field_t("walk", F_FUNCTION, FFL_NOSPAWN),
- new field_t("run", F_FUNCTION, FFL_NOSPAWN),
- new field_t("dodge", F_FUNCTION, FFL_NOSPAWN),
- new field_t("attack", F_FUNCTION, FFL_NOSPAWN),
- new field_t("melee", F_FUNCTION, FFL_NOSPAWN),
- new field_t("sight", F_FUNCTION, FFL_NOSPAWN),
- new field_t("checkattack", F_FUNCTION, FFL_NOSPAWN),
- new field_t("currentmove", F_MMOVE, FFL_NOSPAWN),
- new field_t("endfunc", F_FUNCTION, FFL_NOSPAWN),
- new field_t("item", F_ITEM)
- //need for item field in edict struct, FFL_SPAWNTEMP item will be skipped on saves
- };
+ public static cvar_t fraglimit= new cvar_t();
+ public static cvar_t timelimit= new cvar_t();
+ public static cvar_t password= new cvar_t();
+ public static cvar_t spectator_password= new cvar_t();
+ public static cvar_t needpass= new cvar_t();
+ public static cvar_t maxclients= new cvar_t();
+ public static cvar_t maxspectators= new cvar_t();
+ public static cvar_t maxentities= new cvar_t();
+ public static cvar_t g_select_empty= new cvar_t();
+ public static cvar_t dedicated= new cvar_t();
+
+ public static cvar_t filterban= new cvar_t();
+
+ public static cvar_t sv_maxvelocity= new cvar_t();
+ public static cvar_t sv_gravity= new cvar_t();
+
+ public static cvar_t sv_rollspeed= new cvar_t();
+ public static cvar_t sv_rollangle= new cvar_t();
+ public static cvar_t gun_x= new cvar_t();
+ public static cvar_t gun_y= new cvar_t();
+ public static cvar_t gun_z= new cvar_t();
+
+ public static cvar_t run_pitch= new cvar_t();
+ public static cvar_t run_roll= new cvar_t();
+ public static cvar_t bob_up= new cvar_t();
+ public static cvar_t bob_pitch= new cvar_t();
+ public static cvar_t bob_roll= new cvar_t();
+
+ public static cvar_t sv_cheats= new cvar_t();
+
+ public static cvar_t flood_msgs= new cvar_t();
+ public static cvar_t flood_persecond= new cvar_t();
+ public static cvar_t flood_waitdelay= new cvar_t();
+
+ public static cvar_t sv_maplist= new cvar_t();
- // temp spawn vars -- only valid when the spawn function is called
- static field_t fields_st[] =
- {
- new field_t("lip", F_INT, FFL_SPAWNTEMP),
- new field_t("distance", F_INT, FFL_SPAWNTEMP),
- new field_t("height", F_INT, FFL_SPAWNTEMP),
- new field_t("noise", F_LSTRING, FFL_SPAWNTEMP),
- new field_t("pausetime", F_FLOAT, FFL_SPAWNTEMP),
- new field_t("item", F_LSTRING, FFL_SPAWNTEMP),
- new field_t("gravity", F_LSTRING, FFL_SPAWNTEMP),
- new field_t("sky", F_LSTRING, FFL_SPAWNTEMP),
- new field_t("skyrotate", F_FLOAT, FFL_SPAWNTEMP),
- new field_t("skyaxis", F_VECTOR, FFL_SPAWNTEMP),
- new field_t("minyaw", F_FLOAT, FFL_SPAWNTEMP),
- new field_t("maxyaw", F_FLOAT, FFL_SPAWNTEMP),
- new field_t("minpitch", F_FLOAT, FFL_SPAWNTEMP),
- new field_t("maxpitch", F_FLOAT, FFL_SPAWNTEMP),
- new field_t("nextmap", F_LSTRING, FFL_SPAWNTEMP),
- };
+ public final static float STOP_EPSILON= 0.1f;
/**
* Slide off of the impacting object
* returns the blocked flags (1 = floor, 2 = step / wall).
*/
- public static int ClipVelocity(float[] in, float[] normal, float[] out, float overbounce)
- {
+ public static int ClipVelocity(float[] in, float[] normal, float[] out, float overbounce) {
float backoff;
float change;
int i, blocked;
- blocked = 0;
+ blocked= 0;
if (normal[2] > 0)
blocked |= 1; // floor
if (normal[2] == 0.0f)
blocked |= 2; // step
- backoff = Math3D.DotProduct(in, normal) * overbounce;
+ backoff= Math3D.DotProduct(in, normal) * overbounce;
- for (i = 0; i < 3; i++)
- {
- change = normal[i] * backoff;
- out[i] = in[i] - change;
+ for (i= 0; i < 3; i++) {
+ change= normal[i] * backoff;
+ out[i]= in[i] - change;
if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON)
- out[i] = 0;
+ out[i]= 0;
}
return blocked;
@@ -222,7 +129,7 @@ public class GameBase extends Globals
2 = wall / step
4 = dead stop
*/
- public final static int MAX_CLIP_PLANES = 5;
+ public final static int MAX_CLIP_PLANES= 5;
/*
=============
@@ -242,19 +149,16 @@ public class GameBase extends Globals
* Call with null as from parameter to search from array beginning.
*/
- public static EdictIterator G_Find(EdictIterator from, EdictFindFilter eff, String s)
- {
+ public static EdictIterator G_Find(EdictIterator from, EdictFindFilter eff, String s) {
if (from == null)
- from = new EdictIterator(0);
+ from= new EdictIterator(0);
else
from.i++;
- for (; from.i < globals.num_edicts; from.i++)
- {
- from.o = g_edicts[from.i];
- if (from.o.classname == null)
- {
+ for (; from.i < globals.num_edicts; from.i++) {
+ from.o= g_edicts[from.i];
+ if (from.o.classname == null) {
Com.Printf("edict with classname = null" + from.o.index);
}
@@ -269,9 +173,8 @@ public class GameBase extends Globals
}
// comfort version (rst)
- public static edict_t G_FindEdict(EdictIterator from, EdictFindFilter eff, String s)
- {
- EdictIterator ei = G_Find(from, eff, s);
+ public static edict_t G_FindEdict(EdictIterator from, EdictFindFilter eff, String s) {
+ EdictIterator ei= G_Find(from, eff, s);
if (ei == null)
return null;
else
@@ -281,27 +184,25 @@ public class GameBase extends Globals
/**
* Returns entities that have origins within a spherical area.
*/
- public static EdictIterator findradius(EdictIterator from, float[] org, float rad)
- {
- float[] eorg = { 0, 0, 0 };
+ public static EdictIterator findradius(EdictIterator from, float[] org, float rad) {
+ float[] eorg= { 0, 0, 0 };
int j;
if (from == null)
- from = new EdictIterator(0);
+ from= new EdictIterator(0);
else
from.i++;
- for (; from.i < globals.num_edicts; from.i++)
- {
- from.o = g_edicts[from.i];
+ for (; from.i < globals.num_edicts; from.i++) {
+ from.o= g_edicts[from.i];
if (!from.o.inuse)
continue;
if (from.o.solid == SOLID_NOT)
continue;
- for (j = 0; j < 3; j++)
- eorg[j] = org[j] - (from.o.s.origin[j] + (from.o.mins[j] + from.o.maxs[j]) * 0.5f);
+ for (j= 0; j < 3; j++)
+ eorg[j]= org[j] - (from.o.s.origin[j] + (from.o.mins[j] + from.o.maxs[j]) * 0.5f);
if (Math3D.VectorLength(eorg) > rad)
continue;
@@ -319,30 +220,26 @@ public class GameBase extends Globals
* null will be returned if the end of the list is reached.
*/
- public static int MAXCHOICES = 8;
+ public static int MAXCHOICES= 8;
- public static edict_t G_PickTarget(String targetname)
- {
- int num_choices = 0;
- edict_t choice[] = new edict_t[MAXCHOICES];
+ public static edict_t G_PickTarget(String targetname) {
+ int num_choices= 0;
+ edict_t choice[]= new edict_t[MAXCHOICES];
- if (targetname == null)
- {
+ if (targetname == null) {
gi.dprintf("G_PickTarget called with null targetname\n");
return null;
}
- EdictIterator es = null;
+ EdictIterator es= null;
- while ((es = G_Find(es, findByTarget, targetname)) != null)
- {
- choice[num_choices++] = es.o;
+ while ((es= G_Find(es, findByTarget, targetname)) != null) {
+ choice[num_choices++]= es.o;
if (num_choices == MAXCHOICES)
break;
}
- if (num_choices == 0)
- {
+ if (num_choices == 0) {
gi.dprintf("G_PickTarget: target " + targetname + " not found\n");
return null;
}
@@ -350,31 +247,26 @@ public class GameBase extends Globals
return choice[Lib.rand() % num_choices];
}
- public static float[] VEC_UP = { 0, -1, 0 };
- public static float[] MOVEDIR_UP = { 0, 0, 1 };
- public static float[] VEC_DOWN = { 0, -2, 0 };
- public static float[] MOVEDIR_DOWN = { 0, 0, -1 };
+ public static float[] VEC_UP= { 0, -1, 0 };
+ public static float[] MOVEDIR_UP= { 0, 0, 1 };
+ public static float[] VEC_DOWN= { 0, -2, 0 };
+ public static float[] MOVEDIR_DOWN= { 0, 0, -1 };
- public static void G_SetMovedir(float[] angles, float[] movedir)
- {
- if (Math3D.VectorCompare(angles, VEC_UP) != 0)
- {
+ public static void G_SetMovedir(float[] angles, float[] movedir) {
+ if (Math3D.VectorCompare(angles, VEC_UP) != 0) {
Math3D.VectorCopy(MOVEDIR_UP, movedir);
}
- else if (Math3D.VectorCompare(angles, VEC_DOWN) != 0)
- {
+ else if (Math3D.VectorCompare(angles, VEC_DOWN) != 0) {
Math3D.VectorCopy(MOVEDIR_DOWN, movedir);
}
- else
- {
+ else {
Math3D.AngleVectors(angles, movedir, null, null);
}
Math3D.VectorClear(angles);
}
- public static String G_CopyString(String in)
- {
+ public static String G_CopyString(String in) {
return new String(in);
}
@@ -384,35 +276,42 @@ public class GameBase extends Globals
============
*/
- public static void G_TouchTriggers(edict_t ent)
- {
+
+ static edict_t touch[]= new edict_t[MAX_EDICTS];
+ public static void G_TouchTriggers(edict_t ent) {
int i, num;
- edict_t touch[] = new edict_t[MAX_EDICTS], hit;
+ edict_t hit;
+
// dead things don't activate triggers!
if ((ent.client != null || (ent.svflags & SVF_MONSTER) != 0) && (ent.health <= 0))
return;
- num = gi.BoxEdicts(ent.absmin, ent.absmax, touch, MAX_EDICTS, AREA_TRIGGERS);
+ num= gi.BoxEdicts(ent.absmin, ent.absmax, touch, MAX_EDICTS, AREA_TRIGGERS);
// be careful, it is possible to have an entity in this
// list removed before we get to it (killtriggered)
- for (i = 0; i < num; i++)
- {
- hit = touch[i];
+ for (i= 0; i < num; i++) {
+ hit= touch[i];
+
if (!hit.inuse)
continue;
if (hit.touch == null)
continue;
+
+ //rst: just for debugging player triggers
+ //if (ent.index == 1)
+ //Com.Printf("trigger:" + hit.classname + "(" + hit.index + ")\n");
+
hit.touch.touch(hit, ent, GameBase.dummyplane, null);
}
}
- public static pushed_t pushed[] = new pushed_t[MAX_EDICTS];
+ public static pushed_t pushed[]= new pushed_t[MAX_EDICTS];
static {
- for (int n = 0; n < MAX_EDICTS; n++)
- pushed[n] = new pushed_t();
+ for (int n= 0; n < MAX_EDICTS; n++)
+ pushed[n]= new pushed_t();
}
public static int pushed_p;
@@ -430,7 +329,7 @@ public class GameBase extends Globals
*/
public static int c_yes, c_no;
- public static int STEPSIZE = 18;
+ public static int STEPSIZE= 18;
// ============================================================================
/*
@@ -439,14 +338,12 @@ public class GameBase extends Globals
================
*/
- public static void G_RunEntity(edict_t ent)
- {
-
+ public static void G_RunEntity(edict_t ent) {
+
if (ent.prethink != null)
ent.prethink.think(ent);
- switch ((int) ent.movetype)
- {
+ switch ((int) ent.movetype) {
case MOVETYPE_PUSH :
case MOVETYPE_STOP :
SV.SV_Physics_Pusher(ent);
@@ -477,20 +374,16 @@ public class GameBase extends Globals
================
*/
- public static int DI_NODIR = -1;
- public static void assert1(boolean cond)
- {
- if (!cond)
- {
+ public static int DI_NODIR= -1;
+ public static void assert1(boolean cond) {
+ if (!cond) {
- try
- {
+ try {
- int a[] = null;
- int b = a[0];
+ int a[]= null;
+ int b= a[0];
}
- catch (Exception e)
- {
+ catch (Exception e) {
System.err.println("assertion failed!");
e.printStackTrace();
}
@@ -498,49 +391,41 @@ public class GameBase extends Globals
}
}
- public static void ClearBounds(float[] mins, float[] maxs)
- {
- mins[0] = mins[1] = mins[2] = 99999;
- maxs[0] = maxs[1] = maxs[2] = -99999;
+ public static void ClearBounds(float[] mins, float[] maxs) {
+ mins[0]= mins[1]= mins[2]= 99999;
+ maxs[0]= maxs[1]= maxs[2]= -99999;
}
- public static void AddPointToBounds(float[] v, float[] mins, float[] maxs)
- {
+ public static void AddPointToBounds(float[] v, float[] mins, float[] maxs) {
int i;
float val;
- for (i = 0; i < 3; i++)
- {
- val = v[i];
+ for (i= 0; i < 3; i++) {
+ val= v[i];
if (val < mins[i])
- mins[i] = val;
+ mins[i]= val;
if (val > maxs[i])
- maxs[i] = val;
+ maxs[i]= val;
}
}
- public static EdictFindFilter findByTarget = new EdictFindFilter()
- {
- public boolean matches(edict_t e, String s)
- {
+ public static EdictFindFilter findByTarget= new EdictFindFilter() {
+ public boolean matches(edict_t e, String s) {
if (e.targetname == null)
return false;
return e.targetname.equalsIgnoreCase(s);
}
};
- public static EdictFindFilter findByClass = new EdictFindFilter()
- {
- public boolean matches(edict_t e, String s)
- {
+ public static EdictFindFilter findByClass= new EdictFindFilter() {
+ public boolean matches(edict_t e, String s) {
return e.classname.equalsIgnoreCase(s);
}
};
//===================================================================
- public static void ShutdownGame()
- {
+ public static void ShutdownGame() {
gi.dprintf("==== ShutdownGame ====\n");
//gi.FreeTags (TAG_LEVEL);
@@ -554,16 +439,14 @@ public class GameBase extends Globals
ClientEndServerFrames
=================
*/
- public static void ClientEndServerFrames()
- {
+ public static void ClientEndServerFrames() {
int i;
edict_t ent;
// calc the player views now that all pushing
// and damage has been added
- for (i = 0; i < maxclients.value; i++)
- {
- ent = g_edicts[1 + i];
+ for (i= 0; i < maxclients.value; i++) {
+ ent= g_edicts[1 + i];
if (!ent.inuse || null == ent.client)
continue;
Game.ClientEndServerFrame(ent);
@@ -578,14 +461,13 @@ public class GameBase extends Globals
Returns the created target changelevel
=================
*/
- public static edict_t CreateTargetChangeLevel(String map)
- {
+ public static edict_t CreateTargetChangeLevel(String map) {
edict_t ent;
- ent = Game.G_Spawn();
- ent.classname = "target_changelevel";
- level.nextmap = map;
- ent.map = level.nextmap;
+ ent= Game.G_Spawn();
+ ent.classname= "target_changelevel";
+ level.nextmap= map;
+ ent.map= level.nextmap;
return ent;
}
@@ -596,37 +478,31 @@ public class GameBase extends Globals
The timelimit or fraglimit has been exceeded
=================
*/
- public static void EndDMLevel()
- {
+ public static void EndDMLevel() {
edict_t ent;
//char * s, * t, * f;
//static const char * seps = " ,\n\r";
String s, t, f;
- String seps = " ,\n\r";
+ String seps= " ,\n\r";
// stay on same level flag
- if (((int) dmflags.value & DF_SAME_LEVEL) != 0)
- {
+ if (((int) dmflags.value & DF_SAME_LEVEL) != 0) {
Game.BeginIntermission(CreateTargetChangeLevel(level.mapname));
return;
}
// see if it's in the map list
- if (sv_maplist.string.length() > 0)
- {
- s = sv_maplist.string;
- f = null;
- StringTokenizer tk = new StringTokenizer(s, seps);
- t = tk.nextToken();
+ if (sv_maplist.string.length() > 0) {
+ s= sv_maplist.string;
+ f= null;
+ StringTokenizer tk= new StringTokenizer(s, seps);
+ t= tk.nextToken();
//t = strtok(s, seps);
- while (t != null)
- {
- if (Q_stricmp(t, level.mapname) == 0)
- {
+ while (t != null) {
+ if (Q_stricmp(t, level.mapname) == 0) {
// it's in the list, go to the next one
- t = tk.nextToken();
- if (t == null)
- { // end of list, go to first one
+ t= tk.nextToken();
+ if (t == null) { // end of list, go to first one
if (f == null) // there isn't a first one, same level
Game.BeginIntermission(CreateTargetChangeLevel(level.mapname));
else
@@ -637,25 +513,23 @@ public class GameBase extends Globals
return;
}
if (f == null)
- f = t;
- t = tk.nextToken();
+ f= t;
+ t= tk.nextToken();
}
}
if (level.nextmap.length() > 0) // go to a specific map
Game.BeginIntermission(CreateTargetChangeLevel(level.nextmap));
- else
- { // search for a changelevel
- EdictIterator edit = null;
- edit = G_Find(edit, findByClass, "target_changelevel");
- if (edit == null)
- { // the map designer didn't include a changelevel,
+ else { // search for a changelevel
+ EdictIterator edit= null;
+ edit= G_Find(edit, findByClass, "target_changelevel");
+ if (edit == null) { // the map designer didn't include a changelevel,
// so create a fake ent that goes back to the same level
Game.BeginIntermission(CreateTargetChangeLevel(level.mapname));
return;
}
- ent = edit.o;
+ ent= edit.o;
Game.BeginIntermission(ent);
}
}
@@ -665,17 +539,15 @@ public class GameBase extends Globals
CheckNeedPass
=================
*/
- public static void CheckNeedPass()
- {
+ public static void CheckNeedPass() {
int need;
// if password or spectator_password has changed, update needpass
// as needed
- if (password.modified || spectator_password.modified)
- {
- password.modified = spectator_password.modified = false;
+ if (password.modified || spectator_password.modified) {
+ password.modified= spectator_password.modified= false;
- need = 0;
+ need= 0;
if ((password.string.length() > 0) && 0 != Q_stricmp(password.string, "none"))
need |= 1;
@@ -691,8 +563,7 @@ public class GameBase extends Globals
CheckDMRules
=================
*/
- public static void CheckDMRules()
- {
+ public static void CheckDMRules() {
int i;
gclient_t cl;
@@ -702,26 +573,21 @@ public class GameBase extends Globals
if (0 == deathmatch.value)
return;
- if (timelimit.value != 0)
- {
- if (level.time >= timelimit.value * 60)
- {
+ if (timelimit.value != 0) {
+ if (level.time >= timelimit.value * 60) {
gi.bprintf(PRINT_HIGH, "Timelimit hit.\n");
EndDMLevel();
return;
}
}
- if (fraglimit.value != 0)
- {
- for (i = 0; i < maxclients.value; i++)
- {
- cl = game.clients[i];
+ if (fraglimit.value != 0) {
+ for (i= 0; i < maxclients.value; i++) {
+ cl= game.clients[i];
if (!g_edicts[i + 1].inuse)
continue;
- if (cl.resp.score >= fraglimit.value)
- {
+ if (cl.resp.score >= fraglimit.value) {
gi.bprintf(PRINT_HIGH, "Fraglimit hit.\n");
EndDMLevel();
return;
@@ -735,28 +601,26 @@ public class GameBase extends Globals
ExitLevel
=============
*/
- public static void ExitLevel()
- {
+ public static void ExitLevel() {
int i;
edict_t ent;
//char command[256];
String command;
- command = "gamemap \"" + level.changemap + "\"\n";
+ command= "gamemap \"" + level.changemap + "\"\n";
gi.AddCommandString(command);
- level.changemap = null;
- level.exitintermission = false;
- level.intermissiontime = 0;
+ level.changemap= null;
+ level.exitintermission= false;
+ level.intermissiontime= 0;
ClientEndServerFrames();
// clear some things before going to next level
- for (i = 0; i < maxclients.value; i++)
- {
- ent = g_edicts[1 + i];
+ for (i= 0; i < maxclients.value; i++) {
+ ent= g_edicts[1 + i];
if (!ent.inuse)
continue;
if (ent.health > ent.client.pers.max_health)
- ent.health = ent.client.pers.max_health;
+ ent.health= ent.client.pers.max_health;
}
}
@@ -768,21 +632,19 @@ public class GameBase extends Globals
Advances the world by 0.1 seconds
================
*/
- public static void G_RunFrame()
- {
+ public static void G_RunFrame() {
int i;
edict_t ent;
level.framenum++;
- level.time = level.framenum * FRAMETIME;
+ level.time= level.framenum * FRAMETIME;
// choose a client for monsters to target this frame
Game.AI_SetSightClient();
// exit intermissions
- if (level.exitintermission)
- {
+ if (level.exitintermission) {
ExitLevel();
return;
}
@@ -792,33 +654,28 @@ public class GameBase extends Globals
// even the world gets a chance to think
//
- for (i = 0; i < globals.num_edicts; i++)
- {
- ent = g_edicts[i];
+ for (i= 0; i < globals.num_edicts; i++) {
+ ent= g_edicts[i];
if (!ent.inuse)
continue;
- level.current_entity = ent;
+ level.current_entity= ent;
VectorCopy(ent.s.origin, ent.s.old_origin);
// if the ground entity moved, make sure we are still on it
- if ((ent.groundentity != null) && (ent.groundentity.linkcount != ent.groundentity_linkcount))
- {
- ent.groundentity = null;
- if (0 == (ent.flags & (FL_SWIM | FL_FLY)) && (ent.svflags & SVF_MONSTER) != 0)
- {
+ if ((ent.groundentity != null) && (ent.groundentity.linkcount != ent.groundentity_linkcount)) {
+ ent.groundentity= null;
+ if (0 == (ent.flags & (FL_SWIM | FL_FLY)) && (ent.svflags & SVF_MONSTER) != 0) {
M.M_CheckGround(ent);
}
}
- if (i > 0 && i <= maxclients.value)
- {
+ if (i > 0 && i <= maxclients.value) {
Game.ClientBeginServerFrame(ent);
continue;
}
-
G_RunEntity(ent);
}
@@ -841,19 +698,16 @@ public class GameBase extends Globals
=================
*/
- public static game_export_t GetGameApi(game_import_t imp)
- {
- gi = imp;
+ public static game_export_t GetGameApi(game_import_t imp) {
+ gi= imp;
- gi.pointcontents = new pmove_t.PointContentsAdapter()
- {
- public int pointcontents(float[] o)
- {
+ gi.pointcontents= new pmove_t.PointContentsAdapter() {
+ public int pointcontents(float[] o) {
return SV_WORLD.SV_PointContents(o);
}
};
- globals.apiversion = GAME_API_VERSION;
+ globals.apiversion= GAME_API_VERSION;
/*
globals.Init = InitGame;
globals.Shutdown = ShutdownGame;
diff --git a/src/jake2/game/GameFuncAdapters.java b/src/jake2/game/GameFuncAdapters.java
index 5d48a6e..a381091 100644
--- a/src/jake2/game/GameFuncAdapters.java
+++ b/src/jake2/game/GameFuncAdapters.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 26.02.2004 by RST.
-// $Id: GameFuncAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
+// $Id: GameFuncAdapters.java,v 1.2 2004-08-22 14:25:11 salomo Exp $
package jake2.game;
@@ -30,8 +30,7 @@ import jake2.Globals;
import jake2.util.*;
import jake2.util.*;
-public class GameFuncAdapters
-{
+public class GameFuncAdapters {
/*
=========================================================
@@ -67,66 +66,58 @@ public class GameFuncAdapters
=========================================================
*/
- public final static int PLAT_LOW_TRIGGER = 1;
- public final static int STATE_TOP = 0;
- public final static int STATE_BOTTOM = 1;
- public final static int STATE_UP = 2;
- public final static int STATE_DOWN = 3;
- public final static int DOOR_START_OPEN = 1;
- public final static int DOOR_REVERSE = 2;
- public final static int DOOR_CRUSHER = 4;
- public final static int DOOR_NOMONSTER = 8;
- public final static int DOOR_TOGGLE = 32;
- public final static int DOOR_X_AXIS = 64;
- public final static int DOOR_Y_AXIS = 128;
+ public final static int PLAT_LOW_TRIGGER= 1;
+ public final static int STATE_TOP= 0;
+ public final static int STATE_BOTTOM= 1;
+ public final static int STATE_UP= 2;
+ public final static int STATE_DOWN= 3;
+ public final static int DOOR_START_OPEN= 1;
+ public final static int DOOR_REVERSE= 2;
+ public final static int DOOR_CRUSHER= 4;
+ public final static int DOOR_NOMONSTER= 8;
+ public final static int DOOR_TOGGLE= 32;
+ public final static int DOOR_X_AXIS= 64;
+ public final static int DOOR_Y_AXIS= 128;
//
// Support routines for movement (changes in origin using velocity)
//
- static EntThinkAdapter Move_Done = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter Move_Done= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
Math3D.VectorClear(ent.velocity);
ent.moveinfo.endfunc.think(ent);
return true;
}
};
- static EntThinkAdapter Move_Final = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter Move_Final= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
- if (ent.moveinfo.remaining_distance == 0)
- {
+ if (ent.moveinfo.remaining_distance == 0) {
Move_Done.think(ent);
return true;
}
Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.remaining_distance / Defines.FRAMETIME, ent.velocity);
- ent.think = Move_Done;
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
+ ent.think= Move_Done;
+ ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
return true;
}
};
- static EntThinkAdapter Move_Begin = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter Move_Begin= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
float frames;
- if ((ent.moveinfo.speed * Defines.FRAMETIME) >= ent.moveinfo.remaining_distance)
- {
+ if ((ent.moveinfo.speed * Defines.FRAMETIME) >= ent.moveinfo.remaining_distance) {
Move_Final.think(ent);
return true;
}
Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.speed, ent.velocity);
- frames = (float) Math.floor((ent.moveinfo.remaining_distance / ent.moveinfo.speed) / Defines.FRAMETIME);
+ frames= (float) Math.floor((ent.moveinfo.remaining_distance / ent.moveinfo.speed) / Defines.FRAMETIME);
ent.moveinfo.remaining_distance -= frames * ent.moveinfo.speed * Defines.FRAMETIME;
- ent.nextthink = GameBase.level.time + (frames * Defines.FRAMETIME);
- ent.think = Move_Final;
+ ent.nextthink= GameBase.level.time + (frames * Defines.FRAMETIME);
+ ent.think= Move_Final;
return true;
}
};
@@ -134,44 +125,37 @@ public class GameFuncAdapters
// Support routines for angular movement (changes in angle using avelocity)
//
- static EntThinkAdapter AngleMove_Done = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter AngleMove_Done= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
Math3D.VectorClear(ent.avelocity);
ent.moveinfo.endfunc.think(ent);
return true;
}
};
- static EntThinkAdapter AngleMove_Final = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- float[] move = { 0, 0, 0 };
+ static EntThinkAdapter AngleMove_Final= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ float[] move= { 0, 0, 0 };
if (ent.moveinfo.state == STATE_UP)
Math3D.VectorSubtract(ent.moveinfo.end_angles, ent.s.angles, move);
else
Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, move);
- if (Math3D.VectorCompare(move, Globals.vec3_origin) != 0)
- {
+ if (Math3D.VectorCompare(move, Globals.vec3_origin) != 0) {
AngleMove_Done.think(ent);
return true;
}
Math3D.VectorScale(move, 1.0f / Defines.FRAMETIME, ent.avelocity);
- ent.think = AngleMove_Done;
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
+ ent.think= AngleMove_Done;
+ ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
return true;
}
};
- static EntThinkAdapter AngleMove_Begin = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- float[] destdelta = { 0, 0, 0 };
+ static EntThinkAdapter AngleMove_Begin= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ float[] destdelta= { 0, 0, 0 };
float len;
float traveltime;
float frames;
@@ -183,32 +167,29 @@ public class GameFuncAdapters
Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, destdelta);
// calculate length of vector
- len = Math3D.VectorLength(destdelta);
+ len= Math3D.VectorLength(destdelta);
// divide by speed to get time to reach dest
- traveltime = len / ent.moveinfo.speed;
+ traveltime= len / ent.moveinfo.speed;
- if (traveltime < Defines.FRAMETIME)
- {
+ if (traveltime < Defines.FRAMETIME) {
AngleMove_Final.think(ent);
return true;
}
- frames = (float) (Math.floor(traveltime / Defines.FRAMETIME));
+ frames= (float) (Math.floor(traveltime / Defines.FRAMETIME));
// scale the destdelta vector by the time spent traveling to get velocity
Math3D.VectorScale(destdelta, 1.0f / traveltime, ent.avelocity);
// set nextthink to trigger a think when dest is reached
- ent.nextthink = GameBase.level.time + frames * Defines.FRAMETIME;
- ent.think = AngleMove_Final;
+ ent.nextthink= GameBase.level.time + frames * Defines.FRAMETIME;
+ ent.think= AngleMove_Final;
return true;
}
};
- static EntThinkAdapter Think_AccelMove = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter Think_AccelMove= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
ent.moveinfo.remaining_distance -= ent.moveinfo.current_speed;
if (ent.moveinfo.current_speed == 0) // starting or blocked
@@ -217,24 +198,20 @@ public class GameFuncAdapters
GameFunc.plat_Accelerate(ent.moveinfo);
// will the entire move complete on next frame?
- if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed)
- {
+ if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) {
Move_Final.think(ent);
return true;
}
Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.current_speed * 10, ent.velocity);
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
- ent.think = Think_AccelMove;
+ ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
+ ent.think= Think_AccelMove;
return true;
}
};
- static EntThinkAdapter plat_hit_top = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- if (0 == (ent.flags & Defines.FL_TEAMSLAVE))
- {
+ static EntThinkAdapter plat_hit_top= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
if (ent.moveinfo.sound_end != 0)
GameBase.gi.sound(
ent,
@@ -243,22 +220,19 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- ent.s.sound = 0;
+ ent.s.sound= 0;
}
- ent.moveinfo.state = STATE_TOP;
+ ent.moveinfo.state= STATE_TOP;
- ent.think = plat_go_down;
- ent.nextthink = GameBase.level.time + 3;
+ ent.think= plat_go_down;
+ ent.nextthink= GameBase.level.time + 3;
return true;
}
};
- static EntThinkAdapter plat_hit_bottom = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter plat_hit_bottom= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
- if (0 == (ent.flags & Defines.FL_TEAMSLAVE))
- {
+ if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
if (ent.moveinfo.sound_end != 0)
GameBase.gi.sound(
ent,
@@ -267,18 +241,15 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- ent.s.sound = 0;
+ ent.s.sound= 0;
}
- ent.moveinfo.state = STATE_BOTTOM;
+ ent.moveinfo.state= STATE_BOTTOM;
return true;
}
};
- static EntThinkAdapter plat_go_down = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- if (0 == (ent.flags & Defines.FL_TEAMSLAVE))
- {
+ static EntThinkAdapter plat_go_down= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
if (ent.moveinfo.sound_start != 0)
GameBase.gi.sound(
ent,
@@ -287,19 +258,16 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- ent.s.sound = ent.moveinfo.sound_middle;
+ ent.s.sound= ent.moveinfo.sound_middle;
}
- ent.moveinfo.state = STATE_DOWN;
+ ent.moveinfo.state= STATE_DOWN;
GameFunc.Move_Calc(ent, ent.moveinfo.end_origin, plat_hit_bottom);
return true;
}
};
- static EntBlockedAdapter plat_blocked = new EntBlockedAdapter()
- {
- public void blocked(edict_t self, edict_t other)
- {
- if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client))
- {
+ static EntBlockedAdapter plat_blocked= new EntBlockedAdapter() {
+ public void blocked(edict_t self, edict_t other) {
+ if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) {
// give it a chance to go away on it's own terms (like gibs)
GameUtil.T_Damage(
other,
@@ -337,31 +305,26 @@ public class GameFuncAdapters
}
};
- static EntUseAdapter Use_Plat = new EntUseAdapter()
- {
- public void use(edict_t ent, edict_t other, edict_t activator)
- {
+ static EntUseAdapter Use_Plat= new EntUseAdapter() {
+ public void use(edict_t ent, edict_t other, edict_t activator) {
if (ent.think != null)
return; // already down
plat_go_down.think(ent);
}
};
- static EntTouchAdapter Touch_Plat_Center = new EntTouchAdapter()
- {
- public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf)
- {
+ static EntTouchAdapter Touch_Plat_Center= new EntTouchAdapter() {
+ public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) {
if (other.client == null)
return;
if (other.health <= 0)
return;
- ent = ent.enemy; // now point at the plat, not the trigger
+ ent= ent.enemy; // now point at the plat, not the trigger
if (ent.moveinfo.state == STATE_BOTTOM)
GameFunc.plat_go_up(ent);
- else if (ent.moveinfo.state == STATE_TOP)
- {
- ent.nextthink = GameBase.level.time + 1; // the player is still on the plat, so delay going down
+ else if (ent.moveinfo.state == STATE_TOP) {
+ ent.nextthink= GameBase.level.time + 1; // the player is still on the plat, so delay going down
}
}
};
@@ -379,10 +342,8 @@ public class GameFuncAdapters
STOP mean it will stop moving instead of pushing entities
*/
- static EntBlockedAdapter rotating_blocked = new EntBlockedAdapter()
- {
- public void blocked(edict_t self, edict_t other)
- {
+ static EntBlockedAdapter rotating_blocked= new EntBlockedAdapter() {
+ public void blocked(edict_t self, edict_t other) {
GameUtil.T_Damage(
other,
self,
@@ -396,10 +357,8 @@ public class GameFuncAdapters
Defines.MOD_CRUSH);
}
};
- static EntTouchAdapter rotating_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
+ static EntTouchAdapter rotating_touch= new EntTouchAdapter() {
+ public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
if (self.avelocity[0] != 0 || self.avelocity[1] != 0 || self.avelocity[2] != 0)
GameUtil.T_Damage(
other,
@@ -414,58 +373,52 @@ public class GameFuncAdapters
Defines.MOD_CRUSH);
}
};
- static EntUseAdapter rotating_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- if (0 == Math3D.VectorCompare(self.avelocity, Globals.vec3_origin))
- {
- self.s.sound = 0;
+ static EntUseAdapter rotating_use= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
+ if (0 == Math3D.VectorCompare(self.avelocity, Globals.vec3_origin)) {
+ self.s.sound= 0;
Math3D.VectorClear(self.avelocity);
- self.touch = null;
+ self.touch= null;
}
- else
- {
- self.s.sound = self.moveinfo.sound_middle;
+ else {
+ self.s.sound= self.moveinfo.sound_middle;
Math3D.VectorScale(self.movedir, self.speed, self.avelocity);
if ((self.spawnflags & 16) != 0)
- self.touch = rotating_touch;
+ self.touch= rotating_touch;
}
}
};
- static EntThinkAdapter SP_func_rotating = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- ent.solid = Defines.SOLID_BSP;
+ static EntThinkAdapter SP_func_rotating= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ ent.solid= Defines.SOLID_BSP;
if ((ent.spawnflags & 32) != 0)
- ent.movetype = Defines.MOVETYPE_STOP;
+ ent.movetype= Defines.MOVETYPE_STOP;
else
- ent.movetype = Defines.MOVETYPE_PUSH;
+ ent.movetype= Defines.MOVETYPE_PUSH;
// set the axis of rotation
Math3D.VectorClear(ent.movedir);
if ((ent.spawnflags & 4) != 0)
- ent.movedir[2] = 1.0f;
+ ent.movedir[2]= 1.0f;
else if ((ent.spawnflags & 8) != 0)
- ent.movedir[0] = 1.0f;
+ ent.movedir[0]= 1.0f;
else // Z_AXIS
- ent.movedir[1] = 1.0f;
+ ent.movedir[1]= 1.0f;
// check for reverse rotation
if ((ent.spawnflags & 2) != 0)
Math3D.VectorNegate(ent.movedir, ent.movedir);
if (0 == ent.speed)
- ent.speed = 100;
+ ent.speed= 100;
if (0 == ent.dmg)
- ent.dmg = 2;
+ ent.dmg= 2;
// ent.moveinfo.sound_middle = "doors/hydro1.wav";
- ent.use = rotating_use;
+ ent.use= rotating_use;
if (ent.dmg != 0)
- ent.blocked = rotating_blocked;
+ ent.blocked= rotating_blocked;
if ((ent.spawnflags & 1) != 0)
ent.use.use(ent, null, null);
@@ -505,58 +458,49 @@ public class GameFuncAdapters
5) in-out
*/
- static EntThinkAdapter button_done = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter button_done= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
- self.moveinfo.state = STATE_BOTTOM;
+ self.moveinfo.state= STATE_BOTTOM;
self.s.effects &= ~Defines.EF_ANIM23;
self.s.effects |= Defines.EF_ANIM01;
return true;
}
};
- static EntThinkAdapter button_return = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.moveinfo.state = STATE_DOWN;
+ static EntThinkAdapter button_return= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ self.moveinfo.state= STATE_DOWN;
GameFunc.Move_Calc(self, self.moveinfo.start_origin, button_done);
- self.s.frame = 0;
+ self.s.frame= 0;
if (self.health != 0)
- self.takedamage = Defines.DAMAGE_YES;
+ self.takedamage= Defines.DAMAGE_YES;
return true;
}
};
- static EntThinkAdapter button_wait = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.moveinfo.state = STATE_TOP;
+ static EntThinkAdapter button_wait= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ self.moveinfo.state= STATE_TOP;
self.s.effects &= ~Defines.EF_ANIM01;
self.s.effects |= Defines.EF_ANIM23;
GameUtil.G_UseTargets(self, self.activator);
- self.s.frame = 1;
- if (self.moveinfo.wait >= 0)
- {
- self.nextthink = GameBase.level.time + self.moveinfo.wait;
- self.think = button_return;
+ self.s.frame= 1;
+ if (self.moveinfo.wait >= 0) {
+ self.nextthink= GameBase.level.time + self.moveinfo.wait;
+ self.think= button_return;
}
return true;
}
};
- static EntThinkAdapter button_fire = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter button_fire= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP)
return true;
- self.moveinfo.state = STATE_UP;
+ self.moveinfo.state= STATE_UP;
if (self.moveinfo.sound_start != 0 && 0 == (self.flags & Defines.FL_TEAMSLAVE))
GameBase.gi.sound(
self,
@@ -569,93 +513,84 @@ public class GameFuncAdapters
return true;
}
};
- static EntUseAdapter button_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.activator = activator;
+ static EntUseAdapter button_use= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
+ self.activator= activator;
button_fire.think(self);
return;
}
};
- static EntTouchAdapter button_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
+ static EntTouchAdapter button_touch= new EntTouchAdapter() {
+ public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
if (null == other.client)
return;
if (other.health <= 0)
return;
- self.activator = other;
+ self.activator= other;
button_fire.think(self);
}
};
- static EntDieAdapter button_killed = new EntDieAdapter()
- {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
- self.activator = attacker;
- self.health = self.max_health;
- self.takedamage = Defines.DAMAGE_NO;
+ static EntDieAdapter button_killed= new EntDieAdapter() {
+ public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
+ self.activator= attacker;
+ self.health= self.max_health;
+ self.takedamage= Defines.DAMAGE_NO;
button_fire.think(self);
}
};
- static EntThinkAdapter SP_func_button = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- float[] abs_movedir = { 0, 0, 0 };
+ static EntThinkAdapter SP_func_button= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ float[] abs_movedir= { 0, 0, 0 };
float dist;
GameBase.G_SetMovedir(ent.s.angles, ent.movedir);
- ent.movetype = Defines.MOVETYPE_STOP;
- ent.solid = Defines.SOLID_BSP;
+ ent.movetype= Defines.MOVETYPE_STOP;
+ ent.solid= Defines.SOLID_BSP;
GameBase.gi.setmodel(ent, ent.model);
if (ent.sounds != 1)
- ent.moveinfo.sound_start = GameBase.gi.soundindex("switches/butn2.wav");
+ ent.moveinfo.sound_start= GameBase.gi.soundindex("switches/butn2.wav");
if (0 == ent.speed)
- ent.speed = 40;
+ ent.speed= 40;
if (0 == ent.accel)
- ent.accel = ent.speed;
+ ent.accel= ent.speed;
if (0 == ent.decel)
- ent.decel = ent.speed;
+ ent.decel= ent.speed;
if (0 == ent.wait)
- ent.wait = 3;
+ ent.wait= 3;
if (0 == GameBase.st.lip)
- GameBase.st.lip = 4;
+ GameBase.st.lip= 4;
Math3D.VectorCopy(ent.s.origin, ent.pos1);
- abs_movedir[0] = (float) Math.abs(ent.movedir[0]);
- abs_movedir[1] = (float) Math.abs(ent.movedir[1]);
- abs_movedir[2] = (float) Math.abs(ent.movedir[2]);
- dist = abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip;
+ abs_movedir[0]= (float) Math.abs(ent.movedir[0]);
+ abs_movedir[1]= (float) Math.abs(ent.movedir[1]);
+ abs_movedir[2]= (float) Math.abs(ent.movedir[2]);
+ dist= abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip;
Math3D.VectorMA(ent.pos1, dist, ent.movedir, ent.pos2);
- ent.use = button_use;
+ ent.use= button_use;
ent.s.effects |= Defines.EF_ANIM01;
- if (ent.health != 0)
- {
- ent.max_health = ent.health;
- ent.die = button_killed;
- ent.takedamage = Defines.DAMAGE_YES;
+ if (ent.health != 0) {
+ ent.max_health= ent.health;
+ ent.die= button_killed;
+ ent.takedamage= Defines.DAMAGE_YES;
}
else if (null == ent.targetname)
- ent.touch = button_touch;
+ ent.touch= button_touch;
- ent.moveinfo.state = STATE_BOTTOM;
+ ent.moveinfo.state= STATE_BOTTOM;
- ent.moveinfo.speed = ent.speed;
- ent.moveinfo.accel = ent.accel;
- ent.moveinfo.decel = ent.decel;
- ent.moveinfo.wait = ent.wait;
+ ent.moveinfo.speed= ent.speed;
+ ent.moveinfo.accel= ent.accel;
+ ent.moveinfo.decel= ent.decel;
+ ent.moveinfo.wait= ent.wait;
Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin);
Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles);
Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin);
@@ -665,12 +600,9 @@ public class GameFuncAdapters
return true;
}
};
- static EntThinkAdapter door_hit_top = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (0 == (self.flags & Defines.FL_TEAMSLAVE))
- {
+ static EntThinkAdapter door_hit_top= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_end != 0)
GameBase.gi.sound(
self,
@@ -679,25 +611,21 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- self.s.sound = 0;
+ self.s.sound= 0;
}
- self.moveinfo.state = STATE_TOP;
+ self.moveinfo.state= STATE_TOP;
if ((self.spawnflags & DOOR_TOGGLE) != 0)
return true;
- if (self.moveinfo.wait >= 0)
- {
- self.think = door_go_down;
- self.nextthink = GameBase.level.time + self.moveinfo.wait;
+ if (self.moveinfo.wait >= 0) {
+ self.think= door_go_down;
+ self.nextthink= GameBase.level.time + self.moveinfo.wait;
}
return true;
}
};
- static EntThinkAdapter door_hit_bottom = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (0 == (self.flags & Defines.FL_TEAMSLAVE))
- {
+ static EntThinkAdapter door_hit_bottom= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_end != 0)
GameBase.gi.sound(
self,
@@ -706,19 +634,16 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- self.s.sound = 0;
+ self.s.sound= 0;
}
- self.moveinfo.state = STATE_BOTTOM;
+ self.moveinfo.state= STATE_BOTTOM;
GameFunc.door_use_areaportals(self, false);
return true;
}
};
- static EntThinkAdapter door_go_down = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (0 == (self.flags & Defines.FL_TEAMSLAVE))
- {
+ static EntThinkAdapter door_go_down= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_start != 0)
GameBase.gi.sound(
self,
@@ -727,15 +652,14 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- self.s.sound = self.moveinfo.sound_middle;
+ self.s.sound= self.moveinfo.sound_middle;
}
- if (self.max_health != 0)
- {
- self.takedamage = Defines.DAMAGE_YES;
- self.health = self.max_health;
+ if (self.max_health != 0) {
+ self.takedamage= Defines.DAMAGE_YES;
+ self.health= self.max_health;
}
- self.moveinfo.state = STATE_DOWN;
+ self.moveinfo.state= STATE_DOWN;
if (Lib.strcmp(self.classname, "func_door") == 0)
GameFunc.Move_Calc(self, self.moveinfo.start_origin, door_hit_bottom);
else if (Lib.strcmp(self.classname, "func_door_rotating") == 0)
@@ -743,24 +667,19 @@ public class GameFuncAdapters
return true;
}
};
- static EntUseAdapter door_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
+ static EntUseAdapter door_use= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
edict_t ent;
if ((self.flags & Defines.FL_TEAMSLAVE) != 0)
return;
- if ((self.spawnflags & DOOR_TOGGLE) != 0)
- {
- if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP)
- {
+ if ((self.spawnflags & DOOR_TOGGLE) != 0) {
+ if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) {
// trigger all paired doors
- for (ent = self; ent != null; ent = ent.teamchain)
- {
- ent.message = null;
- ent.touch = null;
+ for (ent= self; ent != null; ent= ent.teamchain) {
+ ent.message= null;
+ ent.touch= null;
door_go_down.think(ent);
}
return;
@@ -768,18 +687,15 @@ public class GameFuncAdapters
}
// trigger all paired doors
- for (ent = self; ent != null; ent = ent.teamchain)
- {
- ent.message = null;
- ent.touch = null;
+ for (ent= self; ent != null; ent= ent.teamchain) {
+ ent.message= null;
+ ent.touch= null;
GameFunc.door_go_up(ent, activator);
}
}
};
- static EntTouchAdapter Touch_DoorTrigger = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
+ static EntTouchAdapter Touch_DoorTrigger= new EntTouchAdapter() {
+ public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
if (other.health <= 0)
return;
@@ -791,15 +707,13 @@ public class GameFuncAdapters
if (GameBase.level.time < self.touch_debounce_time)
return;
- self.touch_debounce_time = GameBase.level.time + 1.0f;
+ self.touch_debounce_time= GameBase.level.time + 1.0f;
door_use.use(self.owner, other, other);
}
};
- static EntThinkAdapter Think_CalcMoveSpeed = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter Think_CalcMoveSpeed= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
edict_t ent;
float min;
float time;
@@ -811,41 +725,37 @@ public class GameFuncAdapters
return true; // only the team master does this
// find the smallest distance any member of the team will be moving
- min = Math.abs(self.moveinfo.distance);
- for (ent = self.teamchain; ent != null; ent = ent.teamchain)
- {
- dist = Math.abs(ent.moveinfo.distance);
+ min= Math.abs(self.moveinfo.distance);
+ for (ent= self.teamchain; ent != null; ent= ent.teamchain) {
+ dist= Math.abs(ent.moveinfo.distance);
if (dist < min)
- min = dist;
+ min= dist;
}
- time = min / self.moveinfo.speed;
+ time= min / self.moveinfo.speed;
// adjust speeds so they will all complete at the same time
- for (ent = self; ent != null; ent = ent.teamchain)
- {
- newspeed = Math.abs(ent.moveinfo.distance) / time;
- ratio = newspeed / ent.moveinfo.speed;
+ for (ent= self; ent != null; ent= ent.teamchain) {
+ newspeed= Math.abs(ent.moveinfo.distance) / time;
+ ratio= newspeed / ent.moveinfo.speed;
if (ent.moveinfo.accel == ent.moveinfo.speed)
- ent.moveinfo.accel = newspeed;
+ ent.moveinfo.accel= newspeed;
else
ent.moveinfo.accel *= ratio;
if (ent.moveinfo.decel == ent.moveinfo.speed)
- ent.moveinfo.decel = newspeed;
+ ent.moveinfo.decel= newspeed;
else
ent.moveinfo.decel *= ratio;
- ent.moveinfo.speed = newspeed;
+ ent.moveinfo.speed= newspeed;
}
return true;
}
};
-
- static EntThinkAdapter Think_SpawnDoorTrigger = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+
+ static EntThinkAdapter Think_SpawnDoorTrigger= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
edict_t other;
- float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 };
+ float[] mins= { 0, 0, 0 }, maxs= { 0, 0, 0 };
if ((ent.flags & Defines.FL_TEAMSLAVE) != 0)
return true; // only the team leader spawns a trigger
@@ -853,8 +763,7 @@ public class GameFuncAdapters
Math3D.VectorCopy(ent.absmin, mins);
Math3D.VectorCopy(ent.absmax, maxs);
- for (other = ent.teamchain; other != null; other = other.teamchain)
- {
+ for (other= ent.teamchain; other != null; other= other.teamchain) {
GameBase.AddPointToBounds(other.absmin, mins, maxs);
GameBase.AddPointToBounds(other.absmax, mins, maxs);
}
@@ -865,13 +774,13 @@ public class GameFuncAdapters
maxs[0] += 60;
maxs[1] += 60;
- other = GameUtil.G_Spawn();
+ other= GameUtil.G_Spawn();
Math3D.VectorCopy(mins, other.mins);
Math3D.VectorCopy(maxs, other.maxs);
- other.owner = ent;
- other.solid = Defines.SOLID_TRIGGER;
- other.movetype = Defines.MOVETYPE_NONE;
- other.touch = Touch_DoorTrigger;
+ other.owner= ent;
+ other.solid= Defines.SOLID_TRIGGER;
+ other.movetype= Defines.MOVETYPE_NONE;
+ other.touch= Touch_DoorTrigger;
GameBase.gi.linkentity(other);
if ((ent.spawnflags & DOOR_START_OPEN) != 0)
@@ -881,14 +790,11 @@ public class GameFuncAdapters
return true;
}
};
- static EntBlockedAdapter door_blocked = new EntBlockedAdapter()
- {
- public void blocked(edict_t self, edict_t other)
- {
+ static EntBlockedAdapter door_blocked= new EntBlockedAdapter() {
+ public void blocked(edict_t self, edict_t other) {
edict_t ent;
- if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client))
- {
+ if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) {
// give it a chance to go away on it's own terms (like gibs)
GameUtil.T_Damage(
other,
@@ -924,124 +830,110 @@ public class GameFuncAdapters
// if a door has a negative wait, it would never come back if blocked,
// so let it just squash the object to death real fast
- if (self.moveinfo.wait >= 0)
- {
- if (self.moveinfo.state == STATE_DOWN)
- {
- for (ent = self.teammaster; ent != null; ent = ent.teamchain)
+ if (self.moveinfo.wait >= 0) {
+ if (self.moveinfo.state == STATE_DOWN) {
+ for (ent= self.teammaster; ent != null; ent= ent.teamchain)
GameFunc.door_go_up(ent, ent.activator);
}
- else
- {
- for (ent = self.teammaster; ent != null; ent = ent.teamchain)
+ else {
+ for (ent= self.teammaster; ent != null; ent= ent.teamchain)
door_go_down.think(ent);
}
}
}
};
- static EntDieAdapter door_killed = new EntDieAdapter()
- {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
+ static EntDieAdapter door_killed= new EntDieAdapter() {
+ public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
edict_t ent;
- for (ent = self.teammaster; ent != null; ent = ent.teamchain)
- {
- ent.health = ent.max_health;
- ent.takedamage = Defines.DAMAGE_NO;
+ for (ent= self.teammaster; ent != null; ent= ent.teamchain) {
+ ent.health= ent.max_health;
+ ent.takedamage= Defines.DAMAGE_NO;
}
door_use.use(self.teammaster, attacker, attacker);
}
};
- static EntTouchAdapter door_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
+ static EntTouchAdapter door_touch= new EntTouchAdapter() {
+ public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
if (null == other.client)
return;
if (GameBase.level.time < self.touch_debounce_time)
return;
- self.touch_debounce_time = GameBase.level.time + 5.0f;
+ self.touch_debounce_time= GameBase.level.time + 5.0f;
GameBase.gi.centerprintf(other, self.message);
GameBase.gi.sound(other, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0);
}
};
- static EntThinkAdapter SP_func_door = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- float[] abs_movedir = { 0, 0, 0 };
-
- if (ent.sounds != 1)
- {
- ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav");
- ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav");
- ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav");
+ static EntThinkAdapter SP_func_door= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ float[] abs_movedir= { 0, 0, 0 };
+
+ if (ent.sounds != 1) {
+ ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav");
+ ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav");
+ ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav");
}
GameBase.G_SetMovedir(ent.s.angles, ent.movedir);
- ent.movetype = Defines.MOVETYPE_PUSH;
- ent.solid = Defines.SOLID_BSP;
+ ent.movetype= Defines.MOVETYPE_PUSH;
+ ent.solid= Defines.SOLID_BSP;
GameBase.gi.setmodel(ent, ent.model);
- ent.blocked = door_blocked;
- ent.use = door_use;
+ ent.blocked= door_blocked;
+ ent.use= door_use;
if (0 == ent.speed)
- ent.speed = 100;
+ ent.speed= 100;
if (GameBase.deathmatch.value != 0)
ent.speed *= 2;
if (0 == ent.accel)
- ent.accel = ent.speed;
+ ent.accel= ent.speed;
if (0 == ent.decel)
- ent.decel = ent.speed;
+ ent.decel= ent.speed;
if (0 == ent.wait)
- ent.wait = 3;
+ ent.wait= 3;
if (0 == GameBase.st.lip)
- GameBase.st.lip = 8;
+ GameBase.st.lip= 8;
if (0 == ent.dmg)
- ent.dmg = 2;
+ ent.dmg= 2;
// calculate second position
Math3D.VectorCopy(ent.s.origin, ent.pos1);
- abs_movedir[0] = Math.abs(ent.movedir[0]);
- abs_movedir[1] = Math.abs(ent.movedir[1]);
- abs_movedir[2] = Math.abs(ent.movedir[2]);
- ent.moveinfo.distance =
+ abs_movedir[0]= Math.abs(ent.movedir[0]);
+ abs_movedir[1]= Math.abs(ent.movedir[1]);
+ abs_movedir[2]= Math.abs(ent.movedir[2]);
+ ent.moveinfo.distance=
abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip;
Math3D.VectorMA(ent.pos1, ent.moveinfo.distance, ent.movedir, ent.pos2);
// if it starts open, switch the positions
- if ((ent.spawnflags & DOOR_START_OPEN) != 0)
- {
+ if ((ent.spawnflags & DOOR_START_OPEN) != 0) {
Math3D.VectorCopy(ent.pos2, ent.s.origin);
Math3D.VectorCopy(ent.pos1, ent.pos2);
Math3D.VectorCopy(ent.s.origin, ent.pos1);
}
- ent.moveinfo.state = STATE_BOTTOM;
+ ent.moveinfo.state= STATE_BOTTOM;
- if (ent.health != 0)
- {
- ent.takedamage = Defines.DAMAGE_YES;
- ent.die = door_killed;
- ent.max_health = ent.health;
+ if (ent.health != 0) {
+ ent.takedamage= Defines.DAMAGE_YES;
+ ent.die= door_killed;
+ ent.max_health= ent.health;
}
- else if (ent.targetname != null && ent.message != null)
- {
+ else if (ent.targetname != null && ent.message != null) {
GameBase.gi.soundindex("misc/talk.wav");
- ent.touch = door_touch;
+ ent.touch= door_touch;
}
- ent.moveinfo.speed = ent.speed;
- ent.moveinfo.accel = ent.accel;
- ent.moveinfo.decel = ent.decel;
- ent.moveinfo.wait = ent.wait;
+ ent.moveinfo.speed= ent.speed;
+ ent.moveinfo.accel= ent.accel;
+ ent.moveinfo.decel= ent.decel;
+ ent.moveinfo.wait= ent.wait;
Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin);
Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles);
Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin);
@@ -1054,15 +946,15 @@ public class GameFuncAdapters
// to simplify logic elsewhere, make non-teamed doors into a team of one
if (null == ent.team)
- ent.teammaster = ent;
+ ent.teammaster= ent;
GameBase.gi.linkentity(ent);
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
+ ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
if (ent.health != 0 || ent.targetname != null)
- ent.think = Think_CalcMoveSpeed;
+ ent.think= Think_CalcMoveSpeed;
else
- ent.think = Think_SpawnDoorTrigger;
+ ent.think= Think_SpawnDoorTrigger;
return true;
}
};
@@ -1095,88 +987,81 @@ public class GameFuncAdapters
4) heavy
*/
- static EntThinkAdapter SP_func_door_rotating = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter SP_func_door_rotating= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
Math3D.VectorClear(ent.s.angles);
// set the axis of rotation
Math3D.VectorClear(ent.movedir);
if ((ent.spawnflags & DOOR_X_AXIS) != 0)
- ent.movedir[2] = 1.0f;
+ ent.movedir[2]= 1.0f;
else if ((ent.spawnflags & DOOR_Y_AXIS) != 0)
- ent.movedir[0] = 1.0f;
+ ent.movedir[0]= 1.0f;
else // Z_AXIS
- ent.movedir[1] = 1.0f;
+ ent.movedir[1]= 1.0f;
// check for reverse rotation
if ((ent.spawnflags & DOOR_REVERSE) != 0)
Math3D.VectorNegate(ent.movedir, ent.movedir);
- if (0 == GameBase.st.distance)
- {
+ if (0 == GameBase.st.distance) {
GameBase.gi.dprintf(ent.classname + " at " + Lib.vtos(ent.s.origin) + " with no distance set\n");
- GameBase.st.distance = 90;
+ GameBase.st.distance= 90;
}
Math3D.VectorCopy(ent.s.angles, ent.pos1);
Math3D.VectorMA(ent.s.angles, GameBase.st.distance, ent.movedir, ent.pos2);
- ent.moveinfo.distance = GameBase.st.distance;
+ ent.moveinfo.distance= GameBase.st.distance;
- ent.movetype = Defines.MOVETYPE_PUSH;
- ent.solid = Defines.SOLID_BSP;
+ ent.movetype= Defines.MOVETYPE_PUSH;
+ ent.solid= Defines.SOLID_BSP;
GameBase.gi.setmodel(ent, ent.model);
- ent.blocked = door_blocked;
- ent.use = door_use;
+ ent.blocked= door_blocked;
+ ent.use= door_use;
if (0 == ent.speed)
- ent.speed = 100;
+ ent.speed= 100;
if (0 == ent.accel)
- ent.accel = ent.speed;
+ ent.accel= ent.speed;
if (0 == ent.decel)
- ent.decel = ent.speed;
+ ent.decel= ent.speed;
if (0 == ent.wait)
- ent.wait = 3;
+ ent.wait= 3;
if (0 == ent.dmg)
- ent.dmg = 2;
+ ent.dmg= 2;
- if (ent.sounds != 1)
- {
- ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav");
- ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav");
- ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav");
+ if (ent.sounds != 1) {
+ ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav");
+ ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav");
+ ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav");
}
// if it starts open, switch the positions
- if ((ent.spawnflags & DOOR_START_OPEN) != 0)
- {
+ if ((ent.spawnflags & DOOR_START_OPEN) != 0) {
Math3D.VectorCopy(ent.pos2, ent.s.angles);
Math3D.VectorCopy(ent.pos1, ent.pos2);
Math3D.VectorCopy(ent.s.angles, ent.pos1);
Math3D.VectorNegate(ent.movedir, ent.movedir);
}
- if (ent.health != 0)
- {
- ent.takedamage = Defines.DAMAGE_YES;
- ent.die = door_killed;
- ent.max_health = ent.health;
+ if (ent.health != 0) {
+ ent.takedamage= Defines.DAMAGE_YES;
+ ent.die= door_killed;
+ ent.max_health= ent.health;
}
- if (ent.targetname != null && ent.message != null)
- {
+ if (ent.targetname != null && ent.message != null) {
GameBase.gi.soundindex("misc/talk.wav");
- ent.touch = door_touch;
+ ent.touch= door_touch;
}
- ent.moveinfo.state = STATE_BOTTOM;
- ent.moveinfo.speed = ent.speed;
- ent.moveinfo.accel = ent.accel;
- ent.moveinfo.decel = ent.decel;
- ent.moveinfo.wait = ent.wait;
+ ent.moveinfo.state= STATE_BOTTOM;
+ ent.moveinfo.speed= ent.speed;
+ ent.moveinfo.accel= ent.accel;
+ ent.moveinfo.decel= ent.decel;
+ ent.moveinfo.wait= ent.wait;
Math3D.VectorCopy(ent.s.origin, ent.moveinfo.start_origin);
Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_angles);
Math3D.VectorCopy(ent.s.origin, ent.moveinfo.end_origin);
@@ -1187,21 +1072,21 @@ public class GameFuncAdapters
// to simplify logic elsewhere, make non-teamed doors into a team of one
if (ent.team == null)
- ent.teammaster = ent;
+ ent.teammaster= ent;
GameBase.gi.linkentity(ent);
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
+ ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
if (ent.health != 0 || ent.targetname != null)
- ent.think = Think_CalcMoveSpeed;
+ ent.think= Think_CalcMoveSpeed;
else
- ent.think = Think_SpawnDoorTrigger;
+ ent.think= Think_SpawnDoorTrigger;
return true;
}
};
- public final static int TRAIN_START_ON = 1;
- public final static int TRAIN_TOGGLE = 2;
- public final static int TRAIN_BLOCK_STOPS = 4;
+ public final static int TRAIN_START_ON= 1;
+ public final static int TRAIN_TOGGLE= 2;
+ public final static int TRAIN_BLOCK_STOPS= 4;
/*QUAKED func_train (0 .5 .8) ? START_ON TOGGLE BLOCK_STOPS
Trains are moving platforms that players can ride.
The targets origin specifies the min point of the train at each corner.
@@ -1213,13 +1098,10 @@ public class GameFuncAdapters
*/
- static EntBlockedAdapter train_blocked = new EntBlockedAdapter()
- {
+ static EntBlockedAdapter train_blocked= new EntBlockedAdapter() {
- public void blocked(edict_t self, edict_t other)
- {
- if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client))
- {
+ public void blocked(edict_t self, edict_t other) {
+ if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) {
// give it a chance to go away on it's own terms (like gibs)
GameUtil.T_Damage(
other,
@@ -1243,7 +1125,7 @@ public class GameFuncAdapters
if (self.dmg == 0)
return;
- self.touch_debounce_time = GameBase.level.time + 0.5f;
+ self.touch_debounce_time= GameBase.level.time + 0.5f;
GameUtil.T_Damage(
other,
self,
@@ -1257,43 +1139,37 @@ public class GameFuncAdapters
Defines.MOD_CRUSH);
}
};
- static EntThinkAdapter train_wait = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.target_ent.pathtarget != null)
- {
+ static EntThinkAdapter train_wait= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ if (self.target_ent.pathtarget != null) {
String savetarget;
edict_t ent;
- ent = self.target_ent;
- savetarget = ent.target;
- ent.target = ent.pathtarget;
+ ent= self.target_ent;
+ savetarget= ent.target;
+ ent.target= ent.pathtarget;
GameUtil.G_UseTargets(ent, self.activator);
- ent.target = savetarget;
+ ent.target= savetarget;
// make sure we didn't get killed by a killtarget
if (!self.inuse)
return true;
}
- if (self.moveinfo.wait != 0)
- {
- if (self.moveinfo.wait > 0)
- {
- self.nextthink = GameBase.level.time + self.moveinfo.wait;
- self.think = train_next;
+ if (self.moveinfo.wait != 0) {
+ if (self.moveinfo.wait > 0) {
+ self.nextthink= GameBase.level.time + self.moveinfo.wait;
+ self.think= train_next;
}
else if (0 != (self.spawnflags & TRAIN_TOGGLE)) // && wait < 0
- {
+ {
train_next.think(self);
self.spawnflags &= ~TRAIN_START_ON;
Math3D.VectorClear(self.velocity);
- self.nextthink = 0;
+ self.nextthink= 0;
}
- if (0 == (self.flags & Defines.FL_TEAMSLAVE))
- {
+ if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_end != 0)
GameBase.gi.sound(
self,
@@ -1302,66 +1178,57 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- self.s.sound = 0;
+ self.s.sound= 0;
}
}
- else
- {
+ else {
train_next.think(self);
}
return true;
}
};
- static EntThinkAdapter train_next = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- edict_t ent = null;
- float[] dest = { 0, 0, 0 };
+ static EntThinkAdapter train_next= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ edict_t ent= null;
+ float[] dest= { 0, 0, 0 };
boolean first;
- first = true;
+ first= true;
- boolean dogoto = true;
- while (dogoto)
- {
- if (null == self.target)
- {
+ boolean dogoto= true;
+ while (dogoto) {
+ if (null == self.target) {
// gi.dprintf ("train_next: no next target\n");
return true;
}
- ent = GameBase.G_PickTarget(self.target);
- if (null == ent)
- {
+ ent= GameBase.G_PickTarget(self.target);
+ if (null == ent) {
GameBase.gi.dprintf("train_next: bad target " + self.target + "\n");
return true;
}
- self.target = ent.target;
- dogoto = false;
+ self.target= ent.target;
+ dogoto= false;
// check for a teleport path_corner
- if ((ent.spawnflags & 1) != 0)
- {
- if (!first)
- {
+ if ((ent.spawnflags & 1) != 0) {
+ if (!first) {
GameBase.gi.dprintf(
"connected teleport path_corners, see " + ent.classname + " at " + Lib.vtos(ent.s.origin) + "\n");
return true;
}
- first = false;
+ first= false;
Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin);
Math3D.VectorCopy(self.s.origin, self.s.old_origin);
- self.s.event = Defines.EV_OTHER_TELEPORT;
+ self.s.event= Defines.EV_OTHER_TELEPORT;
GameBase.gi.linkentity(self);
- dogoto = true;
+ dogoto= true;
}
}
- self.moveinfo.wait = ent.wait;
- self.target_ent = ent;
+ self.moveinfo.wait= ent.wait;
+ self.target_ent= ent;
- if (0 == (self.flags & Defines.FL_TEAMSLAVE))
- {
+ if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_start != 0)
GameBase.gi.sound(
self,
@@ -1370,11 +1237,11 @@ public class GameFuncAdapters
1,
Defines.ATTN_STATIC,
0);
- self.s.sound = self.moveinfo.sound_middle;
+ self.s.sound= self.moveinfo.sound_middle;
}
Math3D.VectorSubtract(ent.s.origin, self.mins, dest);
- self.moveinfo.state = STATE_TOP;
+ self.moveinfo.state= STATE_TOP;
Math3D.VectorCopy(self.s.origin, self.moveinfo.start_origin);
Math3D.VectorCopy(dest, self.moveinfo.end_origin);
GameFunc.Move_Calc(self, dest, train_wait);
@@ -1382,24 +1249,20 @@ public class GameFuncAdapters
return true;
}
};
- public static EntThinkAdapter func_train_find = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ public static EntThinkAdapter func_train_find= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
edict_t ent;
- if (null == self.target)
- {
+ if (null == self.target) {
GameBase.gi.dprintf("train_find: no target\n");
return true;
}
- ent = GameBase.G_PickTarget(self.target);
- if (null == ent)
- {
+ ent= GameBase.G_PickTarget(self.target);
+ if (null == ent) {
GameBase.gi.dprintf("train_find: target " + self.target + " not found\n");
return true;
}
- self.target = ent.target;
+ self.target= ent.target;
Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin);
GameBase.gi.linkentity(self);
@@ -1408,31 +1271,26 @@ public class GameFuncAdapters
if (null == self.targetname)
self.spawnflags |= TRAIN_START_ON;
- if ((self.spawnflags & TRAIN_START_ON) != 0)
- {
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- self.think = train_next;
- self.activator = self;
+ if ((self.spawnflags & TRAIN_START_ON) != 0) {
+ self.nextthink= GameBase.level.time + Defines.FRAMETIME;
+ self.think= train_next;
+ self.activator= self;
}
return true;
}
};
- public static EntUseAdapter train_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.activator = activator;
-
- if ((self.spawnflags & TRAIN_START_ON) != 0)
- {
+ public static EntUseAdapter train_use= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
+ self.activator= activator;
+
+ if ((self.spawnflags & TRAIN_START_ON) != 0) {
if (0 == (self.spawnflags & TRAIN_TOGGLE))
return;
self.spawnflags &= ~TRAIN_START_ON;
Math3D.VectorClear(self.velocity);
- self.nextthink = 0;
+ self.nextthink= 0;
}
- else
- {
+ else {
if (self.target_ent != null)
GameFunc.train_resume(self);
else
@@ -1442,68 +1300,56 @@ public class GameFuncAdapters
};
/*QUAKED trigger_elevator (0.3 0.1 0.6) (-8 -8 -8) (8 8 8)
*/
- static EntUseAdapter trigger_elevator_use = new EntUseAdapter()
- {
+ static EntUseAdapter trigger_elevator_use= new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
+ public void use(edict_t self, edict_t other, edict_t activator) {
edict_t target;
- if (0 != self.movetarget.nextthink)
- {
+ if (0 != self.movetarget.nextthink) {
// gi.dprintf("elevator busy\n");
return;
}
- if (null == other.pathtarget)
- {
+ if (null == other.pathtarget) {
GameBase.gi.dprintf("elevator used with no pathtarget\n");
return;
}
- target = GameBase.G_PickTarget(other.pathtarget);
- if (null == target)
- {
+ target= GameBase.G_PickTarget(other.pathtarget);
+ if (null == target) {
GameBase.gi.dprintf("elevator used with bad pathtarget: " + other.pathtarget + "\n");
return;
}
- self.movetarget.target_ent = target;
+ self.movetarget.target_ent= target;
GameFunc.train_resume(self.movetarget);
}
};
- static EntThinkAdapter trigger_elevator_init = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (null == self.target)
- {
+ static EntThinkAdapter trigger_elevator_init= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ if (null == self.target) {
GameBase.gi.dprintf("trigger_elevator has no target\n");
return true;
}
- self.movetarget = GameBase.G_PickTarget(self.target);
- if (null == self.movetarget)
- {
+ self.movetarget= GameBase.G_PickTarget(self.target);
+ if (null == self.movetarget) {
GameBase.gi.dprintf("trigger_elevator unable to find target " + self.target + "\n");
return true;
}
- if (Lib.strcmp(self.movetarget.classname, "func_train") != 0)
- {
+ if (Lib.strcmp(self.movetarget.classname, "func_train") != 0) {
GameBase.gi.dprintf("trigger_elevator target " + self.target + " is not a train\n");
return true;
}
- self.use = trigger_elevator_use;
- self.svflags = Defines.SVF_NOCLIENT;
+ self.use= trigger_elevator_use;
+ self.svflags= Defines.SVF_NOCLIENT;
return true;
}
};
- static EntThinkAdapter SP_trigger_elevator = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.think = trigger_elevator_init;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
+ static EntThinkAdapter SP_trigger_elevator= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ self.think= trigger_elevator_init;
+ self.nextthink= GameBase.level.time + Defines.FRAMETIME;
return true;
}
};
@@ -1522,31 +1368,26 @@ public class GameFuncAdapters
These can used but not touched.
*/
- static EntThinkAdapter func_timer_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter func_timer_think= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
GameUtil.G_UseTargets(self, self.activator);
- self.nextthink = GameBase.level.time + self.wait + Lib.crandom() * self.random;
+ self.nextthink= GameBase.level.time + self.wait + Lib.crandom() * self.random;
return true;
}
};
- static EntUseAdapter func_timer_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.activator = activator;
+ static EntUseAdapter func_timer_use= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
+ self.activator= activator;
// if on, turn it off
- if (self.nextthink != 0)
- {
- self.nextthink = 0;
+ if (self.nextthink != 0) {
+ self.nextthink= 0;
return;
}
// turn it on
if (self.delay != 0)
- self.nextthink = GameBase.level.time + self.delay;
+ self.nextthink= GameBase.level.time + self.delay;
else
func_timer_think.think(self);
}
@@ -1557,43 +1398,36 @@ public class GameFuncAdapters
speed default 100
*/
- static EntUseAdapter func_conveyor_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- if ((self.spawnflags & 1) != 0)
- {
- self.speed = 0;
+ static EntUseAdapter func_conveyor_use= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
+ if ((self.spawnflags & 1) != 0) {
+ self.speed= 0;
self.spawnflags &= ~1;
}
- else
- {
- self.speed = self.count;
+ else {
+ self.speed= self.count;
self.spawnflags |= 1;
}
if (0 == (self.spawnflags & 2))
- self.count = 0;
+ self.count= 0;
}
};
- static EntThinkAdapter SP_func_conveyor = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter SP_func_conveyor= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
if (0 == self.speed)
- self.speed = 100;
+ self.speed= 100;
- if (0 == (self.spawnflags & 1))
- {
- self.count = (int) self.speed;
- self.speed = 0;
+ if (0 == (self.spawnflags & 1)) {
+ self.count= (int) self.speed;
+ self.speed= 0;
}
- self.use = func_conveyor_use;
+ self.use= func_conveyor_use;
GameBase.gi.setmodel(self, self.model);
- self.solid = Defines.SOLID_BSP;
+ self.solid= Defines.SOLID_BSP;
GameBase.gi.linkentity(self);
return true;
}
@@ -1611,14 +1445,12 @@ public class GameFuncAdapters
"wait" how long to hold in the open position (default 5, -1 means hold)
*/
- public final static int SECRET_ALWAYS_SHOOT = 1;
- public final static int SECRET_1ST_LEFT = 2;
- public final static int SECRET_1ST_DOWN = 4;
- static EntUseAdapter door_secret_use = new EntUseAdapter()
- {
+ public final static int SECRET_ALWAYS_SHOOT= 1;
+ public final static int SECRET_1ST_LEFT= 2;
+ public final static int SECRET_1ST_DOWN= 4;
+ static EntUseAdapter door_secret_use= new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
+ public void use(edict_t self, edict_t other, edict_t activator) {
// make sure we're not already moving
if (0 == Math3D.VectorCompare(self.s.origin, Globals.vec3_origin))
return;
@@ -1627,80 +1459,62 @@ public class GameFuncAdapters
GameFunc.door_use_areaportals(self, true);
}
};
- static EntThinkAdapter door_secret_move1 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.nextthink = GameBase.level.time + 1.0f;
- self.think = door_secret_move2;
+ static EntThinkAdapter door_secret_move1= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ self.nextthink= GameBase.level.time + 1.0f;
+ self.think= door_secret_move2;
return true;
}
};
- static EntThinkAdapter door_secret_move2 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter door_secret_move2= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
GameFunc.Move_Calc(self, self.pos2, door_secret_move3);
return true;
}
};
- static EntThinkAdapter door_secret_move3 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter door_secret_move3= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
if (self.wait == -1)
return true;
- self.nextthink = GameBase.level.time + self.wait;
- self.think = door_secret_move4;
+ self.nextthink= GameBase.level.time + self.wait;
+ self.think= door_secret_move4;
return true;
}
};
- static EntThinkAdapter door_secret_move4 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter door_secret_move4= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
GameFunc.Move_Calc(self, self.pos1, door_secret_move5);
return true;
}
};
- static EntThinkAdapter door_secret_move5 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.nextthink = GameBase.level.time + 1.0f;
- self.think = door_secret_move6;
+ static EntThinkAdapter door_secret_move5= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ self.nextthink= GameBase.level.time + 1.0f;
+ self.think= door_secret_move6;
return true;
}
};
- static EntThinkAdapter door_secret_move6 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
+ static EntThinkAdapter door_secret_move6= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
GameFunc.Move_Calc(self, Globals.vec3_origin, door_secret_done);
return true;
}
};
- static EntThinkAdapter door_secret_done = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (null == (self.targetname) || 0 != (self.spawnflags & SECRET_ALWAYS_SHOOT))
- {
- self.health = 0;
- self.takedamage = Defines.DAMAGE_YES;
+ static EntThinkAdapter door_secret_done= new EntThinkAdapter() {
+ public boolean think(edict_t self) {
+ if (null == (self.targetname) || 0 != (self.spawnflags & SECRET_ALWAYS_SHOOT)) {
+ self.health= 0;
+ self.takedamage= Defines.DAMAGE_YES;
}
GameFunc.door_use_areaportals(self, false);
return true;
}
};
- static EntBlockedAdapter door_secret_blocked = new EntBlockedAdapter()
- {
+ static EntBlockedAdapter door_secret_blocked= new EntBlockedAdapter() {
- public void blocked(edict_t self, edict_t other)
- {
- if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client))
- {
+ public void blocked(edict_t self, edict_t other) {
+ if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) {
// give it a chance to go away on it's own terms (like gibs)
GameUtil.T_Damage(
other,
@@ -1721,7 +1535,7 @@ public class GameFuncAdapters
if (GameBase.level.time < self.touch_debounce_time)
return;
- self.touch_debounce_time = GameBase.level.time + 0.5f;
+ self.touch_debounce_time= GameBase.level.time + 0.5f;
GameUtil.T_Damage(
other,
@@ -1736,77 +1550,70 @@ public class GameFuncAdapters
Defines.MOD_CRUSH);
}
};
- static EntDieAdapter door_secret_die = new EntDieAdapter()
- {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
- self.takedamage = Defines.DAMAGE_NO;
+ static EntDieAdapter door_secret_die= new EntDieAdapter() {
+ public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
+ self.takedamage= Defines.DAMAGE_NO;
door_secret_use.use(self, attacker, attacker);
}
};
- static EntThinkAdapter SP_func_door_secret = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
+ static EntThinkAdapter SP_func_door_secret= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
+ float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 };
float side;
float width;
float length;
- ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav");
- ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav");
- ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav");
+ ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav");
+ ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav");
+ ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav");
- ent.movetype = Defines.MOVETYPE_PUSH;
- ent.solid = Defines.SOLID_BSP;
+ ent.movetype= Defines.MOVETYPE_PUSH;
+ ent.solid= Defines.SOLID_BSP;
GameBase.gi.setmodel(ent, ent.model);
- ent.blocked = door_secret_blocked;
- ent.use = door_secret_use;
+ ent.blocked= door_secret_blocked;
+ ent.use= door_secret_use;
- if (null == (ent.targetname) || 0 != (ent.spawnflags & SECRET_ALWAYS_SHOOT))
- {
- ent.health = 0;
- ent.takedamage = Defines.DAMAGE_YES;
- ent.die = door_secret_die;
+ if (null == (ent.targetname) || 0 != (ent.spawnflags & SECRET_ALWAYS_SHOOT)) {
+ ent.health= 0;
+ ent.takedamage= Defines.DAMAGE_YES;
+ ent.die= door_secret_die;
}
if (0 == ent.dmg)
- ent.dmg = 2;
+ ent.dmg= 2;
if (0 == ent.wait)
- ent.wait = 5;
+ ent.wait= 5;
- ent.moveinfo.accel = ent.moveinfo.decel = ent.moveinfo.speed = 50;
+ ent.moveinfo.accel= ent.moveinfo.decel= ent.moveinfo.speed= 50;
// calculate positions
Math3D.AngleVectors(ent.s.angles, forward, right, up);
Math3D.VectorClear(ent.s.angles);
- side = 1.0f - (ent.spawnflags & SECRET_1ST_LEFT);
+ side= 1.0f - (ent.spawnflags & SECRET_1ST_LEFT);
if ((ent.spawnflags & SECRET_1ST_DOWN) != 0)
- width = Math.abs(Math3D.DotProduct(up, ent.size));
+ width= Math.abs(Math3D.DotProduct(up, ent.size));
else
- width = Math.abs(Math3D.DotProduct(right, ent.size));
- length = Math.abs(Math3D.DotProduct(forward, ent.size));
+ width= Math.abs(Math3D.DotProduct(right, ent.size));
+ length= Math.abs(Math3D.DotProduct(forward, ent.size));
if ((ent.spawnflags & SECRET_1ST_DOWN) != 0)
Math3D.VectorMA(ent.s.origin, -1 * width, up, ent.pos1);
else
Math3D.VectorMA(ent.s.origin, side * width, right, ent.pos1);
Math3D.VectorMA(ent.pos1, length, forward, ent.pos2);
- if (ent.health != 0)
- {
- ent.takedamage = Defines.DAMAGE_YES;
- ent.die = door_killed;
- ent.max_health = ent.health;
+ if (ent.health != 0) {
+ ent.takedamage= Defines.DAMAGE_YES;
+ ent.die= door_killed;
+ ent.max_health= ent.health;
}
- else if (ent.targetname != null && ent.message != null)
- {
+ else if (ent.targetname != null && ent.message != null) {
GameBase.gi.soundindex("misc/talk.wav");
- ent.touch = door_touch;
+ ent.touch= door_touch;
}
- ent.classname = "func_door";
+ ent.classname= "func_door";
GameBase.gi.linkentity(ent);
return true;
@@ -1815,20 +1622,16 @@ public class GameFuncAdapters
/*QUAKED func_killbox (1 0 0) ?
Kills everything inside when fired, irrespective of protection.
*/
- static EntUseAdapter use_killbox = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
+ static EntUseAdapter use_killbox= new EntUseAdapter() {
+ public void use(edict_t self, edict_t other, edict_t activator) {
GameUtil.KillBox(self);
}
};
- static EntThinkAdapter SP_func_killbox = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
+ static EntThinkAdapter SP_func_killbox= new EntThinkAdapter() {
+ public boolean think(edict_t ent) {
GameBase.gi.setmodel(ent, ent.model);
- ent.use = use_killbox;
- ent.svflags = Defines.SVF_NOCLIENT;
+ ent.use= use_killbox;
+ ent.svflags= Defines.SVF_NOCLIENT;
return true;
}
};
diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java
index ba36e06..7db262e 100644
--- a/src/jake2/game/GameSave.java
+++ b/src/jake2/game/GameSave.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 29.12.2003 by RST.
-// $Id: GameSave.java,v 1.2 2004-08-20 21:29:57 salomo Exp $
+// $Id: GameSave.java,v 1.3 2004-08-22 14:25:12 salomo Exp $
package jake2.game;
@@ -37,7 +37,7 @@ import jake2.util.*;
public class GameSave extends GameFunc {
- public static field_t levelfields[] =
+ public static field_t levelfields[]=
{
new field_t("changemap", F_LSTRING),
new field_t("sight_client", F_EDICT),
@@ -46,7 +46,7 @@ public class GameSave extends GameFunc {
new field_t("sound2_entity", F_EDICT),
new field_t(null, F_INT)};
- public static field_t clientfields[] =
+ public static field_t clientfields[]=
{
new field_t("pers.weapon", F_ITEM),
new field_t("pers.lastweapon", F_ITEM),
@@ -54,16 +54,16 @@ public class GameSave extends GameFunc {
new field_t(null, F_INT)};
public static void CreateEdicts() {
- g_edicts = new edict_t[game.maxentities];
- for (int i = 0; i < game.maxentities; i++)
- g_edicts[i] = new edict_t(i);
- SV_GAME.ge.edicts = g_edicts;
+ g_edicts= new edict_t[game.maxentities];
+ for (int i= 0; i < game.maxentities; i++)
+ g_edicts[i]= new edict_t(i);
+ SV_GAME.ge.edicts= g_edicts;
}
public static void CreateClients() {
- game.clients = new gclient_t[game.maxclients];
- for (int i = 0; i < game.maxclients; i++)
- game.clients[i] = new gclient_t(i);
+ game.clients= new gclient_t[game.maxclients];
+ for (int i= 0; i < game.maxclients; i++)
+ game.clients[i]= new gclient_t(i);
}
@@ -79,75 +79,75 @@ public class GameSave extends GameFunc {
public static void InitGame() {
gi.dprintf("==== InitGame ====\n");
- gun_x = gi.cvar("gun_x", "0", 0);
- gun_y = gi.cvar("gun_y", "0", 0);
- gun_z = gi.cvar("gun_z", "0", 0);
+ gun_x= gi.cvar("gun_x", "0", 0);
+ gun_y= gi.cvar("gun_y", "0", 0);
+ gun_z= gi.cvar("gun_z", "0", 0);
//FIXME: sv_ prefix is wrong for these
- sv_rollspeed = gi.cvar("sv_rollspeed", "200", 0);
- sv_rollangle = gi.cvar("sv_rollangle", "2", 0);
- sv_maxvelocity = gi.cvar("sv_maxvelocity", "2000", 0);
- sv_gravity = gi.cvar("sv_gravity", "800", 0);
+ sv_rollspeed= gi.cvar("sv_rollspeed", "200", 0);
+ sv_rollangle= gi.cvar("sv_rollangle", "2", 0);
+ sv_maxvelocity= gi.cvar("sv_maxvelocity", "2000", 0);
+ sv_gravity= gi.cvar("sv_gravity", "800", 0);
// noset vars
- dedicated = gi.cvar("dedicated", "0", CVAR_NOSET);
+ dedicated= gi.cvar("dedicated", "0", CVAR_NOSET);
// latched vars
- sv_cheats = gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
+ sv_cheats= gi.cvar("cheats", "0", CVAR_SERVERINFO | CVAR_LATCH);
gi.cvar("gamename", GAMEVERSION, CVAR_SERVERINFO | CVAR_LATCH);
gi.cvar("gamedate", __DATE__, CVAR_SERVERINFO | CVAR_LATCH);
- maxclients = gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
- maxspectators = gi.cvar("maxspectators", "4", CVAR_SERVERINFO);
- deathmatch = gi.cvar("deathmatch", "0", CVAR_LATCH);
- coop = gi.cvar("coop", "0", CVAR_LATCH);
- skill = gi.cvar("skill", "0", CVAR_LATCH);
- maxentities = gi.cvar("maxentities", "1024", CVAR_LATCH);
+ maxclients= gi.cvar("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
+ maxspectators= gi.cvar("maxspectators", "4", CVAR_SERVERINFO);
+ deathmatch= gi.cvar("deathmatch", "0", CVAR_LATCH);
+ coop= gi.cvar("coop", "0", CVAR_LATCH);
+ skill= gi.cvar("skill", "0", CVAR_LATCH);
+ maxentities= gi.cvar("maxentities", "1024", CVAR_LATCH);
// change anytime vars
- dmflags = gi.cvar("dmflags", "0", CVAR_SERVERINFO);
- fraglimit = gi.cvar("fraglimit", "0", CVAR_SERVERINFO);
- timelimit = gi.cvar("timelimit", "0", CVAR_SERVERINFO);
- password = gi.cvar("password", "", CVAR_USERINFO);
- spectator_password = gi.cvar("spectator_password", "", CVAR_USERINFO);
- needpass = gi.cvar("needpass", "0", CVAR_SERVERINFO);
- filterban = gi.cvar("filterban", "1", 0);
-
- g_select_empty = gi.cvar("g_select_empty", "0", CVAR_ARCHIVE);
-
- run_pitch = gi.cvar("run_pitch", "0.002", 0);
- run_roll = gi.cvar("run_roll", "0.005", 0);
- bob_up = gi.cvar("bob_up", "0.005", 0);
- bob_pitch = gi.cvar("bob_pitch", "0.002", 0);
- bob_roll = gi.cvar("bob_roll", "0.002", 0);
+ dmflags= gi.cvar("dmflags", "0", CVAR_SERVERINFO);
+ fraglimit= gi.cvar("fraglimit", "0", CVAR_SERVERINFO);
+ timelimit= gi.cvar("timelimit", "0", CVAR_SERVERINFO);
+ password= gi.cvar("password", "", CVAR_USERINFO);
+ spectator_password= gi.cvar("spectator_password", "", CVAR_USERINFO);
+ needpass= gi.cvar("needpass", "0", CVAR_SERVERINFO);
+ filterban= gi.cvar("filterban", "1", 0);
+
+ g_select_empty= gi.cvar("g_select_empty", "0", CVAR_ARCHIVE);
+
+ run_pitch= gi.cvar("run_pitch", "0.002", 0);
+ run_roll= gi.cvar("run_roll", "0.005", 0);
+ bob_up= gi.cvar("bob_up", "0.005", 0);
+ bob_pitch= gi.cvar("bob_pitch", "0.002", 0);
+ bob_roll= gi.cvar("bob_roll", "0.002", 0);
// flood control
- flood_msgs = gi.cvar("flood_msgs", "4", 0);
- flood_persecond = gi.cvar("flood_persecond", "4", 0);
- flood_waitdelay = gi.cvar("flood_waitdelay", "10", 0);
+ flood_msgs= gi.cvar("flood_msgs", "4", 0);
+ flood_persecond= gi.cvar("flood_persecond", "4", 0);
+ flood_waitdelay= gi.cvar("flood_waitdelay", "10", 0);
// dm map list
- sv_maplist = gi.cvar("sv_maplist", "", 0);
+ sv_maplist= gi.cvar("sv_maplist", "", 0);
// items
InitItems();
- game.helpmessage1 = "";
- game.helpmessage2 = "";
+ game.helpmessage1= "";
+ game.helpmessage2= "";
// initialize all entities for this game
- game.maxentities = (int) maxentities.value;
+ game.maxentities= (int) maxentities.value;
CreateEdicts();
- globals.edicts = g_edicts;
- globals.max_edicts = game.maxentities;
+ globals.edicts= g_edicts;
+ globals.max_edicts= game.maxentities;
// initialize all clients for this game
- game.maxclients = (int) maxclients.value;
+ game.maxclients= (int) maxclients.value;
CreateClients();
-
- globals.num_edicts = game.maxclients + 1;
+
+ globals.num_edicts= game.maxclients + 1;
}
/*
@@ -164,53 +164,49 @@ public class GameSave extends GameFunc {
last save position.
============
*/
- public static void WriteGame (String filename, boolean autosave)
- {
- try
- {
- QuakeFile f;
-
+ public static void WriteGame(String filename, boolean autosave) {
+ try {
+ QuakeFile f;
+
if (!autosave)
SaveClientData();
-
- f = new QuakeFile(filename, "rw");
-
+
+ f= new QuakeFile(filename, "rw");
+
if (f == null)
- gi.error ("Couldn't write to " + filename);
-
- game.autosaved = autosave;
+ gi.error("Couldn't write to " + filename);
+
+ game.autosaved= autosave;
game.write(f);
- game.autosaved = false;
-
- for (int i=0 ; i<game.maxclients ; i++)
- game.clients[i]. write(f);
-
- fclose (f);
+ game.autosaved= false;
+
+ for (int i= 0; i < game.maxclients; i++)
+ game.clients[i].write(f);
+
+ fclose(f);
}
- catch (Exception e)
- {
+ catch (Exception e) {
e.printStackTrace();
}
}
-
public static void ReadGame(String filename) {
- QuakeFile f = null;
+ QuakeFile f= null;
try {
- f = new QuakeFile(filename, "r");
+ f= new QuakeFile(filename, "r");
Com.Printf("loading game:" + filename);
CreateEdicts();
game.load(f);
- for (int i = 0; i < game.maxclients; i++) {
- game.clients[i] = new gclient_t(i);
+ for (int i= 0; i < game.maxclients; i++) {
+ game.clients[i]= new gclient_t(i);
game.clients[i].read(f);
}
-
+
f.close();
}
@@ -218,51 +214,46 @@ public class GameSave extends GameFunc {
e.printStackTrace();
}
}
-
+
/*
=================
WriteLevel
=================
*/
- static void WriteLevel (String filename)
- {
- try
- {
+ static void WriteLevel(String filename) {
+ try {
int i;
edict_t ent;
QuakeFile f;
-
+
f= new QuakeFile(filename, "rw");
- if (f==null)
+ if (f == null)
gi.error("Couldn't open for writing: " + filename);
-
+
// write out level_locals_t
level.write(f);
-
+
// write out all the entities
- for (i= 0; i < globals.num_edicts; i++)
- {
+ for (i= 0; i < globals.num_edicts; i++) {
ent= g_edicts[i];
if (!ent.inuse)
- continue;
- f.writeInt(i);
+ continue;
+ f.writeInt(i);
ent.write(f);
-
+
}
-
+
i= -1;
f.writeInt(-1);
-
+
f.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
e.printStackTrace();
}
}
-
-
+
/*
=================
ReadLevel
@@ -279,62 +270,63 @@ public class GameSave extends GameFunc {
No clients are connected yet.
=================
*/
- static void ReadLevel (String filename) throws IOException
- {
- edict_t ent;
-
- QuakeFile f = new QuakeFile(filename, "r");
-
- if (f==null)
- gi.error ("Couldn't read level file " + filename);
-
- // wipe all the entities
- Game.CreateEdicts();
-
- globals.num_edicts = (int) maxclients.value + 1;
+ static void ReadLevel(String filename) {
+ try {
+ edict_t ent;
- // load the level locals
- level.read(f);
-
- // load all the entities
- while (true)
- {
- int entnum = f.readInt();
- if (entnum == -1)
- break;
-
- if (entnum >= globals.num_edicts)
- globals.num_edicts = entnum + 1;
-
- ent = g_edicts[entnum];
- System.out.println("readint ent" + entnum);
- ent.read(f);
- ent.cleararealinks();
- gi.linkentity(ent);
- }
-
- fclose (f);
-
- // mark all clients as unconnected
- for (int i=0 ; i<maxclients.value ; i++)
- {
- ent = g_edicts[i+1];
- ent.client = game.clients[i];
- ent.client.pers.connected = false;
+ QuakeFile f= new QuakeFile(filename, "r");
+
+ if (f == null)
+ gi.error("Couldn't read level file " + filename);
+
+ // wipe all the entities
+ Game.CreateEdicts();
+
+ globals.num_edicts= (int) maxclients.value + 1;
+
+ // load the level locals
+ level.read(f);
+
+ // load all the entities
+ while (true) {
+ int entnum= f.readInt();
+ if (entnum == -1)
+ break;
+
+ if (entnum >= globals.num_edicts)
+ globals.num_edicts= entnum + 1;
+
+ ent= g_edicts[entnum];
+ System.out.println("readint ent" + entnum);
+ ent.read(f);
+ ent.cleararealinks();
+ gi.linkentity(ent);
+ }
+
+ fclose(f);
+
+ // mark all clients as unconnected
+ for (int i= 0; i < maxclients.value; i++) {
+ ent= g_edicts[i + 1];
+ ent.client= game.clients[i];
+ ent.client.pers.connected= false;
+ }
+
+ // do any load time things at this point
+ for (int i= 0; i < globals.num_edicts; i++) {
+ ent= g_edicts[i];
+
+ if (!ent.inuse)
+ continue;
+
+ // fire any cross-level triggers
+ if (ent.classname != null)
+ if (strcmp(ent.classname, "target_crosslevel_target") == 0)
+ ent.nextthink= level.time + ent.delay;
+ }
}
-
- // do any load time things at this point
- for (int i=0 ; i<globals.num_edicts ; i++)
- {
- ent = g_edicts[i];
-
- if (!ent.inuse)
- continue;
-
- // fire any cross-level triggers
- if (ent.classname != null)
- if (strcmp(ent.classname, "target_crosslevel_target") == 0)
- ent.nextthink = level.time + ent.delay;
+ catch (Exception e) {
+ e.printStackTrace();
}
}
}
diff --git a/src/jake2/game/edict_t.java b/src/jake2/game/edict_t.java
index a132072..ef2e4a6 100644
--- a/src/jake2/game/edict_t.java
+++ b/src/jake2/game/edict_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 04.11.2003 by RST.
-// $Id: edict_t.java,v 1.3 2004-08-20 21:29:57 salomo Exp $
+// $Id: edict_t.java,v 1.4 2004-08-22 14:25:12 salomo Exp $
package jake2.game;
@@ -29,19 +29,16 @@ import java.io.RandomAccessFile;
import jake2.*;
import jake2.util.*;
-public class edict_t
-{
+public class edict_t {
/** Constructor. */
- public edict_t(int i)
- {
+ public edict_t(int i) {
s.number= i;
index= i;
}
/** Used during level loading. */
- public void cleararealinks()
- {
+ public void cleararealinks() {
area= new link_t(this);
}
@@ -219,201 +216,167 @@ public class edict_t
/////////////////////////////////////////////////
- public boolean set(String key, String value)
- {
+ public boolean set(String key, String value) {
- if (key.equals("classname"))
- {
+ if (key.equals("classname")) {
classname= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("model"))
- {
+ if (key.equals("model")) {
model= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("spawnflags"))
- {
+ if (key.equals("spawnflags")) {
spawnflags= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("speed"))
- {
+ if (key.equals("speed")) {
speed= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("accel"))
- {
+ if (key.equals("accel")) {
accel= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("decel"))
- {
+ if (key.equals("decel")) {
decel= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("target"))
- {
+ if (key.equals("target")) {
target= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("targetname"))
- {
+ if (key.equals("targetname")) {
targetname= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("pathtarget"))
- {
+ if (key.equals("pathtarget")) {
pathtarget= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("deathtarget"))
- {
+ if (key.equals("deathtarget")) {
deathtarget= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("killtarget"))
- {
+ if (key.equals("killtarget")) {
killtarget= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("combattarget"))
- {
+ if (key.equals("combattarget")) {
combattarget= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("message"))
- {
+ if (key.equals("message")) {
message= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("team"))
- {
+ if (key.equals("team")) {
team= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("wait"))
- {
+ if (key.equals("wait")) {
wait= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("delay"))
- {
+ if (key.equals("delay")) {
delay= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("random"))
- {
+ if (key.equals("random")) {
random= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("move_origin"))
- {
+ if (key.equals("move_origin")) {
move_origin= Lib.atov(value);
return true;
} // F_VECTOR),
- if (key.equals("move_angles"))
- {
+ if (key.equals("move_angles")) {
move_angles= Lib.atov(value);
return true;
} // F_VECTOR),
- if (key.equals("style"))
- {
+ if (key.equals("style")) {
style= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("count"))
- {
+ if (key.equals("count")) {
count= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("health"))
- {
+ if (key.equals("health")) {
health= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("sounds"))
- {
+ if (key.equals("sounds")) {
sounds= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("light"))
- {
+ if (key.equals("light")) {
return true;
} // F_IGNORE),
- if (key.equals("dmg"))
- {
+ if (key.equals("dmg")) {
dmg= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("mass"))
- {
+ if (key.equals("mass")) {
mass= Lib.atoi(value);
return true;
} // F_INT),
- if (key.equals("volume"))
- {
+ if (key.equals("volume")) {
volume= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("attenuation"))
- {
+ if (key.equals("attenuation")) {
attenuation= Lib.atof(value);
return true;
} // F_FLOAT),
- if (key.equals("map"))
- {
+ if (key.equals("map")) {
map= GameSpawn.ED_NewString(value);
return true;
} // F_LSTRING),
- if (key.equals("origin"))
- {
+ if (key.equals("origin")) {
s.origin= Lib.atov(value);
return true;
} // F_VECTOR),
- if (key.equals("angles"))
- {
+ if (key.equals("angles")) {
s.angles= Lib.atov(value);
return true;
} // F_VECTOR),
- if (key.equals("angle"))
- {
+ if (key.equals("angle")) {
s.angles= new float[] { 0, Lib.atof(value), 0 };
return true;
} // F_ANGLEHACK),
- if (key.equals("item"))
- {
+ if (key.equals("item")) {
Game.gi.error("ent.set(\"item\") called.");
return true;
} // F_ITEM)
@@ -422,8 +385,7 @@ public class edict_t
}
/** Writes the entity to the file. */
- public void write(QuakeFile f) throws IOException
- {
+ public void write(QuakeFile f) throws IOException {
s.write(f);
f.writeBoolean(inuse);
@@ -434,8 +396,7 @@ public class edict_t
if (clusternums == null)
f.writeInt(-1);
- else
- {
+ else {
f.writeInt(Defines.MAX_ENT_CLUSTERS);
for (int n= 0; n < Defines.MAX_ENT_CLUSTERS; n++)
f.writeInt(clusternums[n]);
@@ -467,6 +428,7 @@ public class edict_t
f.writeString(target);
f.writeString(targetname);
+ f.writeString(killtarget);
f.writeString(team);
f.writeString(pathtarget);
f.writeString(deathtarget);
@@ -582,8 +544,7 @@ public class edict_t
}
/** Reads the entity from the file.*/
- public void read(QuakeFile f) throws IOException
- {
+ public void read(QuakeFile f) throws IOException {
s.read(f);
inuse= f.readBoolean();
linkcount= f.readInt();
@@ -596,8 +557,7 @@ public class edict_t
if (len == -1)
clusternums= null;
- else
- {
+ else {
clusternums= new int[Defines.MAX_ENT_CLUSTERS];
for (int n= 0; n < Defines.MAX_ENT_CLUSTERS; n++)
clusternums[n]= f.readInt();
@@ -629,6 +589,7 @@ public class edict_t
target= f.readString();
targetname= f.readString();
+ killtarget= f.readString();
team= f.readString();
pathtarget= f.readString();
deathtarget= f.readString();
diff --git a/src/jake2/game/game_export_t.java b/src/jake2/game/game_export_t.java
index 38df9db..cfc0610 100644
--- a/src/jake2/game/game_export_t.java
+++ b/src/jake2/game/game_export_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: game_export_t.java,v 1.4 2004-08-20 21:29:58 salomo Exp $
+// $Id: game_export_t.java,v 1.5 2004-08-22 14:25:11 salomo Exp $
package jake2.game;
@@ -34,26 +34,22 @@ import jake2.util.QuakeFile;
//functions exported by the game subsystem
//
-public class game_export_t
-{
+public class game_export_t {
public int apiversion;
// the init function will only be called when a game starts,
// not each time a level is loaded. Persistant data for clients
// and the server can be allocated in init
- public void Init()
- {
+ public void Init() {
Game.InitGame();
}
- public void Shutdown()
- {
+ public void Shutdown() {
Game.ShutdownGame();
}
// each new level entered will cause a call to SpawnEntities
- public void SpawnEntities(String mapname, String entstring, String spawnpoint)
- {
+ public void SpawnEntities(String mapname, String entstring, String spawnpoint) {
Game.SpawnEntities(mapname, entstring, spawnpoint);
}
@@ -61,73 +57,48 @@ public class game_export_t
// about the world state and the clients.
// WriteGame is called every time a level is exited.
// ReadGame is called on a loadgame.
- public void WriteGame(String filename, boolean autosave)
- {
+ public void WriteGame(String filename, boolean autosave) {
GameSave.WriteGame(filename, autosave);
}
- public void ReadGame(String filename)
- {
+ public void ReadGame(String filename) {
Game.ReadGame(filename);
}
// ReadLevel is called after the default map information has been
// loaded with SpawnEntities
- public void WriteLevel(String filename)
- {
- try
- {
- GameSave.WriteLevel(filename);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
+ public void WriteLevel(String filename) {
+ GameSave.WriteLevel(filename);
}
- public void ReadLevel(String filename)
- {
- try
- {
- GameSave.ReadLevel(filename);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
+ public void ReadLevel(String filename) {
+ GameSave.ReadLevel(filename);
}
- public boolean ClientConnect(edict_t ent, String userinfo)
- {
+ public boolean ClientConnect(edict_t ent, String userinfo) {
return PlayerClient.ClientConnect(ent, userinfo);
}
-
- public void ClientBegin(edict_t ent)
- {
+
+ public void ClientBegin(edict_t ent) {
PlayerClient.ClientBegin(ent);
}
-
- public void ClientUserinfoChanged(edict_t ent, String userinfo)
- {
+
+ public void ClientUserinfoChanged(edict_t ent, String userinfo) {
PlayerClient.ClientUserinfoChanged(ent, userinfo);
}
-
- public void ClientDisconnect(edict_t ent)
- {
+
+ public void ClientDisconnect(edict_t ent) {
PlayerClient.ClientDisconnect(ent);
}
- public void ClientCommand(edict_t ent)
- {
+ public void ClientCommand(edict_t ent) {
PlayerClient.ClientCommand(ent);
}
- public void ClientThink(edict_t ent, usercmd_t cmd)
- {
+ public void ClientThink(edict_t ent, usercmd_t cmd) {
PlayerClient.ClientThink(ent, cmd);
}
- public void RunFrame()
- {
+ public void RunFrame() {
Game.G_RunFrame();
}
@@ -135,8 +106,7 @@ public class game_export_t
// server console.
// the game can issue gi.argc() / gi.argv() commands to get the rest
// of the parameters
- public void ServerCommand()
- {
+ public void ServerCommand() {
Game.ServerCommand();
}
@@ -148,7 +118,7 @@ public class game_export_t
// can vary in size from one game to another.
// the size will be fixed when ge.Init() is called
- public edict_t edicts[] = Game.g_edicts;
+ public edict_t edicts[]= Game.g_edicts;
public int num_edicts; // current number, <= max_edicts
public int max_edicts;
-} \ No newline at end of file
+}
diff --git a/src/jake2/game/game_import_t.java b/src/jake2/game/game_import_t.java
index 8c7bd5f..940867f 100644
--- a/src/jake2/game/game_import_t.java
+++ b/src/jake2/game/game_import_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: game_import_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
+// $Id: game_import_t.java,v 1.3 2004-08-22 14:25:11 salomo Exp $
package jake2.game;
@@ -40,8 +40,6 @@ import jake2.server.SV_WORLD;
//
public class game_import_t
{
- // R S T: SEE SV_InitGameProgs() !
-
// special messages
public void bprintf(int printlevel, String s)
{
diff --git a/src/jake2/qcommon/PMove.java b/src/jake2/qcommon/PMove.java
index 75459fc..f8d0a2f 100644
--- a/src/jake2/qcommon/PMove.java
+++ b/src/jake2/qcommon/PMove.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 25.01.2004 by RST.
-// $Id: PMove.java,v 1.2 2004-07-08 15:58:46 hzi Exp $
+// $Id: PMove.java,v 1.3 2004-08-22 14:25:14 salomo Exp $
package jake2.qcommon;
@@ -160,6 +160,7 @@ public class PMove extends Game
// save entity for contact
if (pm.numtouch < MAXTOUCH && trace.ent != null)
{
+ //rst: just for debugging touches.
//if (trace.ent.index != -1 && trace.ent.index != 0)
//Com.p("touch: " + trace.ent.classname + " (" + trace.ent.index + ")" );
@@ -1256,5 +1257,4 @@ public class PMove extends Game
PM_SnapPosition();
}
-
}
diff --git a/src/jake2/render/fastjogl/Draw.java b/src/jake2/render/fastjogl/Draw.java
index 3098697..d3c62b6 100644
--- a/src/jake2/render/fastjogl/Draw.java
+++ b/src/jake2/render/fastjogl/Draw.java
@@ -2,7 +2,7 @@
* Draw.java
* Copyright (C) 2003
*
- * $Id: Draw.java,v 1.3 2004-07-16 10:11:35 cawe Exp $
+ * $Id: Draw.java,v 1.4 2004-08-22 14:25:14 salomo Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -275,7 +275,7 @@ public abstract class Draw extends Image {
gl.glEnable(GL.GL_TEXTURE_2D);
}
-// =============================================================================
+ //=============================================================================
/*
================
diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java
index 540e3ea..b8e8e7e 100644
--- a/src/jake2/server/SV.java
+++ b/src/jake2/server/SV.java
@@ -2,7 +2,7 @@
* SV.java
* Copyright (C) 2003
*
- * $Id: SV.java,v 1.6 2004-08-20 21:29:57 salomo Exp $
+ * $Id: SV.java,v 1.7 2004-08-22 14:25:12 salomo Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -849,7 +849,7 @@ public final class SV
GameBase.gi.sound(ent, 0, GameBase.gi.soundindex("world/land.wav"), 1, 1, 0);
}
- // regular thinking
+ // regular thinking
SV_RunThink(ent);
}
diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java
index a5b509f..8ab3e72 100644
--- a/src/jake2/server/SV_CCMDS.java
+++ b/src/jake2/server/SV_CCMDS.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 18.01.2004 by RST.
-// $Id: SV_CCMDS.java,v 1.6 2004-08-20 21:29:57 salomo Exp $
+// $Id: SV_CCMDS.java,v 1.7 2004-08-22 14:25:12 salomo Exp $
package jake2.server;
@@ -35,8 +35,7 @@ import jake2.util.Vargs;
import java.io.*;
import java.util.Calendar;
-public class SV_CCMDS extends SV_ENTS
-{
+public class SV_CCMDS extends SV_ENTS {
/*
===============================================================================
@@ -54,13 +53,11 @@ public class SV_CCMDS extends SV_ENTS
Specify a list of master servers
====================
*/
- public static void SV_SetMaster_f()
- {
+ public static void SV_SetMaster_f() {
int i, slot;
// only dedicated servers send heartbeats
- if (dedicated.value == 0)
- {
+ if (dedicated.value == 0) {
Com.Printf("Only dedicated servers use masters.\n");
return;
}
@@ -73,13 +70,11 @@ public class SV_CCMDS extends SV_ENTS
master_adr[i]= new netadr_t();
slot= 1; // slot 0 will always contain the id master
- for (i= 1; i < Cmd.Argc(); i++)
- {
+ for (i= 1; i < Cmd.Argc(); i++) {
if (slot == MAX_MASTERS)
break;
- if (!NET.StringToAdr(Cmd.Argv(i), master_adr[i]))
- {
+ if (!NET.StringToAdr(Cmd.Argv(i), master_adr[i])) {
Com.Printf("Bad address: " + Cmd.Argv(i) + "\n");
continue;
}
@@ -106,8 +101,7 @@ public class SV_CCMDS extends SV_ENTS
Sets sv_client and sv_player to the player with idnum Cmd.Argv(1)
==================
*/
- public static boolean SV_SetPlayer()
- {
+ public static boolean SV_SetPlayer() {
client_t cl;
int i;
int idnum;
@@ -119,19 +113,16 @@ public class SV_CCMDS extends SV_ENTS
s= Cmd.Argv(1);
// numeric values are just slot numbers
- if (s.charAt(0) >= '0' && s.charAt(0) <= '9')
- {
+ if (s.charAt(0) >= '0' && s.charAt(0) <= '9') {
idnum= atoi(Cmd.Argv(1));
- if (idnum < 0 || idnum >= maxclients.value)
- {
+ if (idnum < 0 || idnum >= maxclients.value) {
Com.Printf("Bad client slot: " + idnum + "\n");
return false;
}
sv_client= svs.clients[idnum];
sv_player= sv_client.edict;
- if (0 == sv_client.state)
- {
+ if (0 == sv_client.state) {
Com.Printf("Client " + idnum + " is not active\n");
return false;
}
@@ -139,13 +130,11 @@ public class SV_CCMDS extends SV_ENTS
}
// check for a name match
- for (i= 0; i < maxclients.value; i++)
- {
+ for (i= 0; i < maxclients.value; i++) {
cl= svs.clients[i];
if (0 == cl.state)
continue;
- if (0 == strcmp(cl.name, s))
- {
+ if (0 == strcmp(cl.name, s)) {
sv_client= cl;
sv_player= sv_client.edict;
return true;
@@ -164,14 +153,11 @@ public class SV_CCMDS extends SV_ENTS
===============================================================================
*/
- public static void remove(String name)
- {
- try
- {
+ public static void remove(String name) {
+ try {
new File(name).delete();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
}
@@ -182,8 +168,7 @@ public class SV_CCMDS extends SV_ENTS
Delete save/<XXX>/
=====================
*/
- public static void SV_WipeSavegame(String savename)
- {
+ public static void SV_WipeSavegame(String savename) {
//char name[MAX_OSPATH];
//char *s;
@@ -200,8 +185,7 @@ public class SV_CCMDS extends SV_ENTS
name= FS.Gamedir() + "/save/" + savename + "/*.sav";
File f= Sys.FindFirst(name, 0, 0);
- while (f != null)
- {
+ while (f != null) {
f.delete();
f= Sys.FindNext();
}
@@ -211,8 +195,7 @@ public class SV_CCMDS extends SV_ENTS
f= Sys.FindFirst(name, 0, 0);
- while (f != null)
- {
+ while (f != null) {
f.delete();
f= Sys.FindNext();
}
@@ -224,80 +207,64 @@ public class SV_CCMDS extends SV_ENTS
CopyFile
================
*/
- public static void CopyFile(String src, String dst)
- {
+ public static void CopyFile(String src, String dst) {
RandomAccessFile f1, f2;
int l= -1;
byte buffer[]= new byte[65536];
Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n");
System.out.println("CopyFile (" + src + ", " + dst + ")\n");
- try
- {
+ try {
f1= new RandomAccessFile(src, "r");
}
- catch (Exception e)
- {
+ catch (Exception e) {
return;
}
- try
- {
+ try {
f2= new RandomAccessFile(dst, "rw");
}
- catch (Exception e)
- {
- try
- {
+ catch (Exception e) {
+ try {
f1.close();
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
e1.printStackTrace();
}
return;
}
- while (true)
- {
+ while (true) {
- try
- {
+ try {
l= f1.read(buffer, 0, 65536);
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
e1.printStackTrace();
}
if (l == -1)
break;
- try
- {
+ try {
f2.write(buffer, 0, l);
}
- catch (IOException e2)
- {
+ catch (IOException e2) {
e2.printStackTrace();
}
}
- try
- {
+ try {
f1.close();
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
e1.printStackTrace();
}
- try
- {
+ try {
f2.close();
}
- catch (IOException e2)
- {
+ catch (IOException e2) {
e2.printStackTrace();
}
@@ -308,8 +275,7 @@ public class SV_CCMDS extends SV_ENTS
SV_CopySaveGame
================
*/
- public static void SV_CopySaveGame(String src, String dst)
- {
+ public static void SV_CopySaveGame(String src, String dst) {
//char name[MAX_OSPATH], name2[MAX_OSPATH];
int l, len;
File found;
@@ -336,11 +302,10 @@ public class SV_CCMDS extends SV_ENTS
found= Sys.FindFirst(name, 0, 0);
- while (found != null)
- {
- name= name1 + found.getName();
+ while (found != null) {
+ name= name1 + found.getName();
name2= FS.Gamedir() + "/save/" + dst + "/" + found.getName();
-
+
CopyFile(name, name2);
// change sav to sv2
@@ -364,8 +329,7 @@ public class SV_CCMDS extends SV_ENTS
==============
*/
- public static void SV_WriteLevelFile()
- {
+ public static void SV_WriteLevelFile() {
String name;
QuakeFile f;
@@ -374,8 +338,7 @@ public class SV_CCMDS extends SV_ENTS
name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2";
- try
- {
+ try {
f= new QuakeFile(name, "rw");
for (int i= 0; i < MAX_CONFIGSTRINGS; i++)
@@ -384,8 +347,7 @@ public class SV_CCMDS extends SV_ENTS
CM.CM_WritePortalState(f);
f.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
Com.Printf("Failed to open " + name + "\n");
e.printStackTrace();
}
@@ -400,8 +362,7 @@ public class SV_CCMDS extends SV_ENTS
==============
*/
- public static void SV_ReadLevelFile()
- {
+ public static void SV_ReadLevelFile() {
//char name[MAX_OSPATH];
String name;
QuakeFile f;
@@ -409,8 +370,7 @@ public class SV_CCMDS extends SV_ENTS
Com.DPrintf("SV_ReadLevelFile()\n");
name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2";
- try
- {
+ try {
f= new QuakeFile(name, "r");
for (int n= 0; n < MAX_CONFIGSTRINGS; n++)
@@ -420,8 +380,7 @@ public class SV_CCMDS extends SV_ENTS
f.close();
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
Com.Printf("Failed to open " + name + "\n");
e1.printStackTrace();
}
@@ -437,8 +396,7 @@ public class SV_CCMDS extends SV_ENTS
==============
*/
- public static void SV_WriteServerFile(boolean autosave)
- {
+ public static void SV_WriteServerFile(boolean autosave) {
QuakeFile f;
cvar_t var;
@@ -447,12 +405,10 @@ public class SV_CCMDS extends SV_ENTS
Com.DPrintf("SV_WriteServerFile(" + (autosave ? "true" : "false") + ")\n");
filename= FS.Gamedir() + "/save/current/server.ssv";
- try
- {
+ try {
f= new QuakeFile(filename, "rw");
- if (!autosave)
- {
+ if (!autosave) {
Calendar c= Calendar.getInstance();
comment=
Com.sprintf(
@@ -461,8 +417,7 @@ public class SV_CCMDS extends SV_ENTS
c.get(Calendar.DAY_OF_MONTH)));
comment += sv.configstrings[CS_NAME];
}
- else
- {
+ else {
// autosaved
comment= "ENTERING " + sv.configstrings[CS_NAME];
}
@@ -474,25 +429,21 @@ public class SV_CCMDS extends SV_ENTS
// write all CVAR_LATCH cvars
// these will be things like coop, skill, deathmatch, etc
- for (var= Globals.cvar_vars; var != null; var= var.next)
- {
+ for (var= Globals.cvar_vars; var != null; var= var.next) {
if (0 == (var.flags & CVAR_LATCH))
continue;
- if (var.name.length() >= MAX_OSPATH - 1 || var.string.length() >= 128 - 1)
- {
+ if (var.name.length() >= MAX_OSPATH - 1 || var.string.length() >= 128 - 1) {
Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n");
continue;
}
name= var.name;
string= var.string;
- try
- {
+ try {
f.writeString(name);
f.writeString(string);
}
- catch (IOException e2)
- {
+ catch (IOException e2) {
}
}
@@ -500,8 +451,7 @@ public class SV_CCMDS extends SV_ENTS
f.writeString(null);
f.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
Com.Printf("Couldn't write " + filename + "\n");
}
@@ -516,11 +466,9 @@ public class SV_CCMDS extends SV_ENTS
==============
*/
- public static void SV_ReadServerFile()
- {
+ public static void SV_ReadServerFile() {
String filename, name= "", string, comment, mapcmd;
- try
- {
+ try {
QuakeFile f;
mapcmd= "";
@@ -541,8 +489,7 @@ public class SV_CCMDS extends SV_ENTS
// read all CVAR_LATCH cvars
// these will be things like coop, skill, deathmatch, etc
- while (true)
- {
+ while (true) {
name= f.readString();
if (name == null)
break;
@@ -563,8 +510,7 @@ public class SV_CCMDS extends SV_ENTS
filename= FS.Gamedir() + "/save/current/game.ssv";
ge.ReadGame(filename);
}
- catch (Exception e)
- {
+ catch (Exception e) {
Com.Printf("Couldn't read file " + name + "\n");
System.err.println(e);
e.printStackTrace();
@@ -580,8 +526,7 @@ public class SV_CCMDS extends SV_ENTS
Puts the server in demo mode on a specific map/cinematic
==================
*/
- public static void SV_DemoMap_f()
- {
+ public static void SV_DemoMap_f() {
SV_Map(true, Cmd.Argv(1), false);
}
@@ -603,15 +548,13 @@ public class SV_CCMDS extends SV_ENTS
goes to map jail.bsp.
==================
*/
- public static void SV_GameMap_f()
- {
+ public static void SV_GameMap_f() {
String map;
int i;
client_t cl;
boolean savedInuse[];
- if (Cmd.Argc() != 2)
- {
+ if (Cmd.Argc() != 2) {
Com.Printf("USAGE: gamemap <map>\n");
return;
}
@@ -622,21 +565,17 @@ public class SV_CCMDS extends SV_ENTS
// check for clearing the current savegame
map= Cmd.Argv(1);
- if (map.charAt(0) == '*')
- {
+ if (map.charAt(0) == '*') {
// wipe all the *.sav files
SV_WipeSavegame("current");
}
- else
- { // save the map just exited
- if (sv.state == ss_game)
- {
+ else { // save the map just exited
+ if (sv.state == ss_game) {
// clear all the client inuse flags before saving so that
// when the level is re-entered, the clients will spawn
// at spawn points instead of occupying body shells
savedInuse= new boolean[(int) maxclients.value];
- for (i= 0; i < maxclients.value; i++)
- {
+ for (i= 0; i < maxclients.value; i++) {
cl= svs.clients[i];
savedInuse[i]= cl.edict.inuse;
cl.edict.inuse= false;
@@ -645,8 +584,7 @@ public class SV_CCMDS extends SV_ENTS
SV_WriteLevelFile();
// we must restore these for clients to transfer over correctly
- for (i= 0; i < maxclients.value; i++)
- {
+ for (i= 0; i < maxclients.value; i++) {
cl= svs.clients[i];
cl.edict.inuse= savedInuse[i];
@@ -662,8 +600,7 @@ public class SV_CCMDS extends SV_ENTS
svs.mapcmd= Cmd.Argv(1);
// copy off the level to the autosave slot
- if (0 == dedicated.value)
- {
+ if (0 == dedicated.value) {
SV_WriteServerFile(true);
SV_CopySaveGame("current", "save0");
}
@@ -677,24 +614,15 @@ public class SV_CCMDS extends SV_ENTS
For development work
==================
*/
- public static void SV_Map_f()
- {
+ public static void SV_Map_f() {
String map;
//char expanded[MAX_QPATH];
String expanded;
// if not a pcx, demo, or cinematic, check to make sure the level exists
-//<<<<<<< SV_CCMDS.java
-// map= Cmd.Argv(1);
-// if (!strstr(map, "."))
-// {
-// expanded= "maps/" + map + ".bsp";
-// if (FS.LoadFile(expanded) == null)
-// {
-//=======
- map = Cmd.Argv(1);
+ map= Cmd.Argv(1);
if (map.indexOf(".") < 0) {
- expanded = "maps/" + map + ".bsp";
+ expanded= "maps/" + map + ".bsp";
if (FS.LoadFile(expanded) == null) {
Com.Printf("Can't find " + expanded + "\n");
@@ -703,7 +631,7 @@ public class SV_CCMDS extends SV_ENTS
}
sv.state= ss_dead; // don't save current level when changing
- //TODO: savegame
+
SV_WipeSavegame("current");
SV_GameMap_f();
}
@@ -722,8 +650,7 @@ public class SV_CCMDS extends SV_ENTS
==============
*/
- public static void SV_Loadgame_f()
- {
+ public static void SV_Loadgame_f() {
//char name[MAX_OSPATH];
//FILE * f;
//char * dir;
@@ -732,8 +659,7 @@ public class SV_CCMDS extends SV_ENTS
RandomAccessFile f;
String dir;
- if (Cmd.Argc() != 2)
- {
+ if (Cmd.Argc() != 2) {
Com.Printf("USAGE: loadgame <directory>\n");
return;
}
@@ -741,29 +667,24 @@ public class SV_CCMDS extends SV_ENTS
Com.Printf("Loading game...\n");
dir= Cmd.Argv(1);
- if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\"))
- {
+ if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) {
Com.Printf("Bad savedir.\n");
}
// make sure the server.ssv file exists
name= FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv";
- try
- {
+ try {
f= new RandomAccessFile(name, "r");
}
- catch (FileNotFoundException e)
- {
+ catch (FileNotFoundException e) {
Com.Printf("No such savegame: " + name + "\n");
return;
}
- try
- {
+ try {
f.close();
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
e1.printStackTrace();
}
@@ -782,43 +703,36 @@ public class SV_CCMDS extends SV_ENTS
==============
*/
- public static void SV_Savegame_f()
- {
+ public static void SV_Savegame_f() {
String dir;
- if (sv.state != ss_game)
- {
+ if (sv.state != ss_game) {
Com.Printf("You must be in a game to save.\n");
return;
}
- if (Cmd.Argc() != 2)
- {
+ if (Cmd.Argc() != 2) {
Com.Printf("USAGE: savegame <directory>\n");
return;
}
- if (Cvar.VariableValue("deathmatch") != 0)
- {
+ if (Cvar.VariableValue("deathmatch") != 0) {
Com.Printf("Can't savegame in a deathmatch\n");
return;
}
- if (0 == strcmp(Cmd.Argv(1), "current"))
- {
+ if (0 == strcmp(Cmd.Argv(1), "current")) {
Com.Printf("Can't save to 'current'\n");
return;
}
- if (maxclients.value == 1 && svs.clients[0].edict.client.ps.stats[STAT_HEALTH] <= 0)
- {
+ if (maxclients.value == 1 && svs.clients[0].edict.client.ps.stats[STAT_HEALTH] <= 0) {
Com.Printf("\nCan't savegame while dead!\n");
return;
}
dir= Cmd.Argv(1);
- if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\"))
- {
+ if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) {
Com.Printf("Bad savedir.\n");
}
@@ -830,12 +744,10 @@ public class SV_CCMDS extends SV_ENTS
SV_WriteLevelFile();
// save server state
- try
- {
+ try {
SV_WriteServerFile(false);
}
- catch (Exception e)
- {
+ catch (Exception e) {
Com.Printf("IOError in SV_WriteServerFile: " + e);
}
@@ -854,16 +766,13 @@ public class SV_CCMDS extends SV_ENTS
Kick a user off of the server
==================
*/
- public static void SV_Kick_f()
- {
- if (!svs.initialized)
- {
+ public static void SV_Kick_f() {
+ if (!svs.initialized) {
Com.Printf("No server running.\n");
return;
}
- if (Cmd.Argc() != 2)
- {
+ if (Cmd.Argc() != 2) {
Com.Printf("Usage: kick <userid>\n");
return;
}
@@ -884,14 +793,12 @@ public class SV_CCMDS extends SV_ENTS
SV_Status_f
================
*/
- public static void SV_Status_f()
- {
+ public static void SV_Status_f() {
int i, j, l;
client_t cl;
String s;
int ping;
- if (svs.clients == null)
- {
+ if (svs.clients == null) {
Com.Printf("No server running.\n");
return;
}
@@ -899,8 +806,7 @@ public class SV_CCMDS extends SV_ENTS
Com.Printf("num score ping name lastmsg address qport \n");
Com.Printf("--- ----- ---- --------------- ------- --------------------- ------\n");
- for (i= 0; i < maxclients.value; i++)
- {
+ for (i= 0; i < maxclients.value; i++) {
cl= svs.clients[i];
if (0 == cl.state)
continue;
@@ -912,8 +818,7 @@ public class SV_CCMDS extends SV_ENTS
Com.Printf("CNCT ");
else if (cl.state == cs_zombie)
Com.Printf("ZMBI ");
- else
- {
+ else {
ping= cl.ping < 9999 ? cl.ping : 9999;
Com.Printf("%4i ", new Vargs().add(ping));
}
@@ -943,8 +848,7 @@ public class SV_CCMDS extends SV_ENTS
SV_ConSay_f
==================
*/
- public static void SV_ConSay_f()
- {
+ public static void SV_ConSay_f() {
client_t client;
int j;
String p;
@@ -956,15 +860,13 @@ public class SV_CCMDS extends SV_ENTS
text= "console: ";
p= Cmd.Args();
- if (p.charAt(0) == '"')
- {
+ if (p.charAt(0) == '"') {
p= p.substring(1, p.length() - 1);
}
text += p;
- for (j= 0; j < maxclients.value; j++)
- {
+ for (j= 0; j < maxclients.value; j++) {
client= svs.clients[j];
if (client.state != cs_spawned)
continue;
@@ -977,8 +879,7 @@ public class SV_CCMDS extends SV_ENTS
SV_Heartbeat_f
==================
*/
- public static void SV_Heartbeat_f()
- {
+ public static void SV_Heartbeat_f() {
svs.last_heartbeat= -9999999;
}
@@ -989,8 +890,7 @@ public class SV_CCMDS extends SV_ENTS
Examine or change the serverinfo string
===========
*/
- public static void SV_Serverinfo_f()
- {
+ public static void SV_Serverinfo_f() {
Com.Printf("Server info settings:\n");
Info.Print(Cvar.Serverinfo());
}
@@ -1002,10 +902,8 @@ public class SV_CCMDS extends SV_ENTS
Examine all a users info strings
===========
*/
- public static void SV_DumpUser_f()
- {
- if (Cmd.Argc() != 2)
- {
+ public static void SV_DumpUser_f() {
+ if (Cmd.Argc() != 2) {
Com.Printf("Usage: info <userid>\n");
return;
}
@@ -1027,8 +925,7 @@ public class SV_CCMDS extends SV_ENTS
recorded, but no playerinfo will be stored. Primarily for demo merging.
==============
*/
- public static void SV_ServerRecord_f()
- {
+ public static void SV_ServerRecord_f() {
//char name[MAX_OSPATH];
String name;
byte buf_data[]= new byte[32768];
@@ -1036,20 +933,17 @@ public class SV_CCMDS extends SV_ENTS
int len;
int i;
- if (Cmd.Argc() != 2)
- {
+ if (Cmd.Argc() != 2) {
Com.Printf("serverrecord <demoname>\n");
return;
}
- if (svs.demofile != null)
- {
+ if (svs.demofile != null) {
Com.Printf("Already recording.\n");
return;
}
- if (sv.state != ss_game)
- {
+ if (sv.state != ss_game) {
Com.Printf("You must be in a level to record.\n");
return;
}
@@ -1061,12 +955,10 @@ public class SV_CCMDS extends SV_ENTS
Com.Printf("recording to " + name + ".\n");
FS.CreatePath(name);
- try
- {
+ try {
svs.demofile= new RandomAccessFile(name, "rw");
}
- catch (Exception e)
- {
+ catch (Exception e) {
Com.Printf("ERROR: couldn't open.\n");
return;
}
@@ -1095,8 +987,7 @@ public class SV_CCMDS extends SV_ENTS
MSG.WriteString(buf, sv.configstrings[CS_NAME]);
for (i= 0; i < MAX_CONFIGSTRINGS; i++)
- if (sv.configstrings[i].length() == 0)
- {
+ if (sv.configstrings[i].length() == 0) {
MSG.WriteByte(buf, svc_configstring);
MSG.WriteShort(buf, i);
MSG.WriteString(buf, sv.configstrings[i]);
@@ -1107,13 +998,11 @@ public class SV_CCMDS extends SV_ENTS
len= EndianHandler.swapInt(buf.cursize);
//fwrite(len, 4, 1, svs.demofile);
//fwrite(buf.data, buf.cursize, 1, svs.demofile);
- try
- {
+ try {
svs.demofile.writeInt(len);
svs.demofile.write(buf.data);
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
// TODO: do quake2 error handling!
e1.printStackTrace();
}
@@ -1128,19 +1017,15 @@ public class SV_CCMDS extends SV_ENTS
Ends server demo recording
==============
*/
- public static void SV_ServerStop_f()
- {
- if (svs.demofile == null)
- {
+ public static void SV_ServerStop_f() {
+ if (svs.demofile == null) {
Com.Printf("Not doing a serverrecord.\n");
return;
}
- try
- {
+ try {
svs.demofile.close();
}
- catch (IOException e)
- {
+ catch (IOException e) {
e.printStackTrace();
}
svs.demofile= null;
@@ -1155,8 +1040,7 @@ public class SV_CCMDS extends SV_ENTS
===============
*/
- public static void SV_KillServer_f()
- {
+ public static void SV_KillServer_f() {
if (!svs.initialized)
return;
SV_Shutdown("Server was killed.\n", false);
@@ -1170,10 +1054,8 @@ public class SV_CCMDS extends SV_ENTS
Let the game dll handle a command
===============
*/
- public static void SV_ServerCommand_f()
- {
- if (SV_GAME.ge == null)
- {
+ public static void SV_ServerCommand_f() {
+ if (SV_GAME.ge == null) {
Com.Printf("No game loaded.\n");
return;
}
@@ -1188,124 +1070,91 @@ public class SV_CCMDS extends SV_ENTS
SV_InitOperatorCommands
==================
*/
- public static void SV_InitOperatorCommands()
- {
- Cmd.AddCommand("heartbeat", new xcommand_t()
- {
- public void execute()
- {
+ public static void SV_InitOperatorCommands() {
+ Cmd.AddCommand("heartbeat", new xcommand_t() {
+ public void execute() {
SV_Heartbeat_f();
}
});
- Cmd.AddCommand("kick", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("kick", new xcommand_t() {
+ public void execute() {
SV_Kick_f();
}
});
- Cmd.AddCommand("status", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("status", new xcommand_t() {
+ public void execute() {
SV_Status_f();
}
});
- Cmd.AddCommand("serverinfo", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("serverinfo", new xcommand_t() {
+ public void execute() {
SV_Serverinfo_f();
}
});
- Cmd.AddCommand("dumpuser", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("dumpuser", new xcommand_t() {
+ public void execute() {
SV_DumpUser_f();
}
});
- Cmd.AddCommand("map", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("map", new xcommand_t() {
+ public void execute() {
SV_Map_f();
}
});
- Cmd.AddCommand("demomap", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("demomap", new xcommand_t() {
+ public void execute() {
SV_DemoMap_f();
}
});
- Cmd.AddCommand("gamemap", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("gamemap", new xcommand_t() {
+ public void execute() {
SV_GameMap_f();
}
});
- Cmd.AddCommand("setmaster", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("setmaster", new xcommand_t() {
+ public void execute() {
SV_SetMaster_f();
}
});
if (dedicated.value != 0)
- Cmd.AddCommand("say", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("say", new xcommand_t() {
+ public void execute() {
SV_ConSay_f();
}
});
- Cmd.AddCommand("serverrecord", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("serverrecord", new xcommand_t() {
+ public void execute() {
SV_ServerRecord_f();
}
});
- Cmd.AddCommand("serverstop", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("serverstop", new xcommand_t() {
+ public void execute() {
SV_ServerStop_f();
}
});
- Cmd.AddCommand("save", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("save", new xcommand_t() {
+ public void execute() {
SV_Savegame_f();
}
});
- Cmd.AddCommand("load", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("load", new xcommand_t() {
+ public void execute() {
SV_Loadgame_f();
}
});
- Cmd.AddCommand("killserver", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("killserver", new xcommand_t() {
+ public void execute() {
SV_KillServer_f();
}
});
- Cmd.AddCommand("sv", new xcommand_t()
- {
- public void execute()
- {
+ Cmd.AddCommand("sv", new xcommand_t() {
+ public void execute() {
SV_ServerCommand_f();
}
});
diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java
index 9e3d8d2..0dc5a8b 100644
--- a/src/jake2/server/SV_GAME.java
+++ b/src/jake2/server/SV_GAME.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_GAME.java,v 1.5 2004-07-09 06:50:49 hzi Exp $
+// $Id: SV_GAME.java,v 1.6 2004-08-22 14:25:12 salomo Exp $
package jake2.server;
@@ -32,8 +32,6 @@ import jake2.sys.Sys;
public class SV_GAME extends SV_INIT {
- // sv_game.c -- interface to the game dll
-
public static game_export_t ge;
/*
@@ -50,7 +48,6 @@ public class SV_GAME extends SV_INIT {
if (ent == null)
return;
- //p = NUM_FOR_EDICT(ent);
p = ent.index;
if (p < 1 || p > SV_MAIN.maxclients.value)
return;
@@ -73,16 +70,6 @@ public class SV_GAME extends SV_INIT {
===============
*/
public static void PF_dprintf(String fmt) {
- /*
- char msg[1024];
- va_list argptr;
-
- va_start (argptr,fmt);
- vsprintf (msg, fmt, argptr);
- va_end (argptr);
-
- */
-
Com.Printf(fmt);
}
@@ -94,22 +81,15 @@ public class SV_GAME extends SV_INIT {
===============
*/
public static void PF_cprintf(edict_t ent, int level, String fmt) {
- //char msg[1024];
- //va_list argptr;
+
int n = 0;
if (ent != null) {
-
- //n = NUM_FOR_EDICT(ent);
n = ent.index;
if (n < 1 || n > SV_MAIN.maxclients.value)
Com.Error(ERR_DROP, "cprintf to a non-client");
}
- // va_start (argptr,fmt);
- // vsprintf (msg, fmt, argptr);
- // va_end (argptr);
-
if (ent != null)
SV_SEND.SV_ClientPrintf(svs.clients[n - 1], level, fmt);
else
@@ -124,20 +104,12 @@ public class SV_GAME extends SV_INIT {
===============
*/
public static void PF_centerprintf(edict_t ent, String fmt) {
- //char msg[1024];
- //va_list argptr;
int n;
- //TODO: NUM_FOR_EDICT
- //n = NUM_FOR_EDICT(ent);
n = ent.index;
if (n < 1 || n > SV_MAIN.maxclients.value)
return; // Com_Error (ERR_DROP, "centerprintf to a non-client");
- // va_start (argptr,fmt);
- // vsprintf (msg, fmt, argptr);
- // va_end (argptr);
-
MSG.WriteByte(sv.multicast, svc_centerprint);
MSG.WriteString(sv.multicast, fmt);
PF_Unicast(ent, true);
@@ -174,7 +146,6 @@ public class SV_GAME extends SV_INIT {
i = SV_ModelIndex(name);
- //ent.model = name;
ent.s.modelindex = i;
// if it is an inline model, get the size information for it
diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java
index b8e5c90..c036d50 100644
--- a/src/jake2/server/SV_INIT.java
+++ b/src/jake2/server/SV_INIT.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_INIT.java,v 1.6 2004-08-20 21:29:57 salomo Exp $
+// $Id: SV_INIT.java,v 1.7 2004-08-22 14:25:13 salomo Exp $
package jake2.server;
@@ -33,8 +33,7 @@ import jake2.sys.NET;
import java.io.IOException;
import java.io.RandomAccessFile;
-public class SV_INIT extends Globals
-{
+public class SV_INIT extends Globals {
public static server_static_t svs= new server_static_t(); // persistant server info
public static server_t sv= new server_t(); // local server
@@ -45,8 +44,7 @@ public class SV_INIT extends Globals
================
*/
- public static int SV_FindIndex(String name, int start, int max, boolean create)
- {
+ public static int SV_FindIndex(String name, int start, int max, boolean create) {
int i;
if (name == null || name.length() == 0)
@@ -65,8 +63,7 @@ public class SV_INIT extends Globals
//strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i]));
sv.configstrings[start + i]= name;
- if (sv.state != ss_loading)
- { // send the update to everyone
+ if (sv.state != ss_loading) { // send the update to everyone
SZ.Clear(sv.multicast);
MSG.WriteChar(sv.multicast, svc_configstring);
MSG.WriteShort(sv.multicast, start + i);
@@ -77,18 +74,15 @@ public class SV_INIT extends Globals
return i;
}
- public static int SV_ModelIndex(String name)
- {
+ public static int SV_ModelIndex(String name) {
return SV_FindIndex(name, CS_MODELS, MAX_MODELS, true);
}
- public static int SV_SoundIndex(String name)
- {
+ public static int SV_SoundIndex(String name) {
return SV_FindIndex(name, CS_SOUNDS, MAX_SOUNDS, true);
}
- public static int SV_ImageIndex(String name)
- {
+ public static int SV_ImageIndex(String name) {
return SV_FindIndex(name, CS_IMAGES, MAX_IMAGES, true);
}
@@ -101,13 +95,11 @@ public class SV_INIT extends Globals
baseline will be transmitted
================
*/
- public static void SV_CreateBaseline()
- {
+ public static void SV_CreateBaseline() {
edict_t svent;
int entnum;
- for (entnum= 1; entnum < SV_GAME.ge.num_edicts; entnum++)
- {
+ for (entnum= 1; entnum < SV_GAME.ge.num_edicts; entnum++) {
//svent = EDICT_NUM(entnum);
svent= SV_GAME.ge.edicts[entnum];
@@ -131,11 +123,9 @@ public class SV_INIT extends Globals
SV_CheckForSavegame
=================
*/
- public static void SV_CheckForSavegame()
- {
- //char name[MAX_OSPATH];
+ public static void SV_CheckForSavegame() {
+
String name;
- //FILE *f;
RandomAccessFile f;
int i;
@@ -147,22 +137,18 @@ public class SV_INIT extends Globals
return;
name= FS.Gamedir() + "/save/current/" + sv.name + ".sav";
- try
- {
+ try {
f= new RandomAccessFile(name, "r");
}
- catch (Exception e)
- {
- return; // no savegame
+ catch (Exception e) {
+ return;
}
- try
- {
+ try {
f.close();
}
- catch (IOException e1)
- {
+ catch (IOException e1) {
e1.printStackTrace();
}
@@ -171,8 +157,7 @@ public class SV_INIT extends Globals
// get configstrings and areaportals
SV_CCMDS.SV_ReadLevelFile();
- if (!sv.loadgame)
- { // coming back to a level after being in a different
+ if (!sv.loadgame) { // coming back to a level after being in a different
// level, so run it for ten seconds
// rlava2 was sending too many lightstyles, and overflowing the
@@ -198,8 +183,7 @@ public class SV_INIT extends Globals
================
*/
- public static void SV_SpawnServer(String server, String spawnpoint, int serverstate, boolean attractloop, boolean loadgame)
- {
+ public static void SV_SpawnServer(String server, String spawnpoint, int serverstate, boolean attractloop, boolean loadgame) {
int i;
int checksum= 0;
@@ -210,21 +194,18 @@ public class SV_INIT extends Globals
Com.DPrintf("SpawnServer: " + server + "\n");
if (sv.demofile != null)
- try
- {
+ try {
sv.demofile.close();
}
- catch (Exception e)
- {
+ catch (Exception e) {
}
svs.spawncount++; // any partially connected client will be
// restarted
- sv.state = ss_dead;
-
- Globals.server_state= sv.state;
+ sv.state= ss_dead;
+ Globals.server_state= sv.state;
// wipe the entire per-level structure
//memset(sv, 0, sizeof(sv));
@@ -237,13 +218,11 @@ public class SV_INIT extends Globals
// save name for levels that don't set message
sv.configstrings[CS_NAME]= server;
- if (Cvar.VariableValue("deathmatch") != 0)
- {
+ if (Cvar.VariableValue("deathmatch") != 0) {
sv.configstrings[CS_AIRACCEL]= "" + SV_MAIN.sv_airaccelerate.value;
PMove.pm_airaccelerate= SV_MAIN.sv_airaccelerate.value;
}
- else
- {
+ else {
sv.configstrings[CS_AIRACCEL]= "0";
PMove.pm_airaccelerate= 0;
}
@@ -253,8 +232,7 @@ public class SV_INIT extends Globals
sv.name= server;
// leave slots at start for clients only
- for (i= 0; i < SV_MAIN.maxclients.value; i++)
- {
+ for (i= 0; i < SV_MAIN.maxclients.value; i++) {
// needs to reconnect
if (svs.clients[i].state > cs_connected)
svs.clients[i].state= cs_connected;
@@ -268,12 +246,10 @@ public class SV_INIT extends Globals
int iw[]= { checksum };
- if (serverstate != ss_game)
- {
+ if (serverstate != ss_game) {
sv.models[1]= CM.CM_LoadMap("", false, iw); // no real map
}
- else
- {
+ else {
sv.configstrings[CS_MODELS + 1]= "maps/" + server + ".bsp";
sv.models[1]= CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw);
}
@@ -285,8 +261,7 @@ public class SV_INIT extends Globals
//
SV_WORLD.SV_ClearWorld();
- for (i= 1; i < CM.CM_NumInlineModels(); i++)
- {
+ for (i= 1; i < CM.CM_NumInlineModels(); i++) {
sv.configstrings[CS_MODELS + 1 + i]= "*" + i;
// copy references
sv.models[i + 1]= CM.InlineModel(sv.configstrings[CS_MODELS + 1 + i]);
@@ -299,7 +274,7 @@ public class SV_INIT extends Globals
// precache and static commands can be issued during
// map initialization
- sv.state = ss_loading;
+ sv.state= ss_loading;
Globals.server_state= sv.state;
// load and spawn all other entities
@@ -310,7 +285,7 @@ public class SV_INIT extends Globals
SV_GAME.ge.RunFrame();
// all precaches are complete
- sv.state = serverstate;
+ sv.state= serverstate;
Globals.server_state= sv.state;
// create a baseline for more efficient communications
@@ -332,20 +307,17 @@ public class SV_INIT extends Globals
A brand new game has been started
==============
*/
- public static void SV_InitGame()
- {
+ public static void SV_InitGame() {
int i;
edict_t ent;
//char idmaster[32];
String idmaster;
- if (svs.initialized)
- {
+ if (svs.initialized) {
// cause any connected clients to reconnect
SV_MAIN.SV_Shutdown("Server restarted\n", true);
}
- else
- {
+ else {
// make sure the client is down
CL.Drop();
SCR.BeginLoadingPlaque();
@@ -356,30 +328,26 @@ public class SV_INIT extends Globals
svs.initialized= true;
- if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0)
- {
+ if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0) {
Com.Printf("Deathmatch and Coop both set, disabling Coop\n");
Cvar.FullSet("coop", "0", CVAR_SERVERINFO | CVAR_LATCH);
}
// dedicated servers are can't be single player and are usually DM
// so unless they explicity set coop, force it to deathmatch
- if (dedicated.value != 0)
- {
+ if (dedicated.value != 0) {
if (0 == Cvar.VariableValue("coop"))
Cvar.FullSet("deathmatch", "1", CVAR_SERVERINFO | CVAR_LATCH);
}
// init clients
- if (Cvar.VariableValue("deathmatch") != 0)
- {
+ if (Cvar.VariableValue("deathmatch") != 0) {
if (SV_MAIN.maxclients.value <= 1)
Cvar.FullSet("maxclients", "8", CVAR_SERVERINFO | CVAR_LATCH);
else if (SV_MAIN.maxclients.value > MAX_CLIENTS)
Cvar.FullSet("maxclients", "" + MAX_CLIENTS, CVAR_SERVERINFO | CVAR_LATCH);
}
- else if (Cvar.VariableValue("coop") != 0)
- {
+ else if (Cvar.VariableValue("coop") != 0) {
if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4)
Cvar.FullSet("maxclients", "4", CVAR_SERVERINFO | CVAR_LATCH);
@@ -413,8 +381,7 @@ public class SV_INIT extends Globals
// init game
SV_GAME.SV_InitGameProgs(); // bis hier alles ok!
- for (i= 0; i < SV_MAIN.maxclients.value; i++)
- {
+ for (i= 0; i < SV_MAIN.maxclients.value; i++) {
ent= SV_GAME.ge.edicts[i + 1];
//ent.s.number = i + 1; //dont need this, ent.s.number already set.
@@ -440,8 +407,7 @@ public class SV_INIT extends Globals
map tram.cin+jail_e3
======================
*/
- public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame)
- {
+ public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame) {
//char level[MAX_QPATH];
//char *ch;
int l;
@@ -470,13 +436,11 @@ public class SV_INIT extends Globals
// Cvar_Set ("nextserver", "");
int c= level.indexOf('+');
- if (c != -1)
- {
+ if (c != -1) {
Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\"");
level= level.substring(0, c);
}
- else
- {
+ else {
Cvar.Set("nextserver", "");
}
@@ -486,8 +450,7 @@ public class SV_INIT extends Globals
// if there is a $, use the remainder as a spawnpoint
int pos= level.indexOf('$');
- if (pos != -1)
- {
+ if (pos != -1) {
//* ch = 0;
spawnpoint= level.substring(pos + 1);
level= level.substring(0, pos);
@@ -502,26 +465,22 @@ public class SV_INIT extends Globals
level= level.substring(1);
l= level.length();
- if (l > 4 && level.endsWith(".cin"))
- {
+ if (l > 4 && level.endsWith(".cin")) {
SCR.BeginLoadingPlaque(); // for local system
SV_SEND.SV_BroadcastCommand("changing\n");
SV_SpawnServer(level, spawnpoint, ss_cinematic, attractloop, loadgame);
}
- else if (l > 4 && level.endsWith(".dm2"))
- {
+ else if (l > 4 && level.endsWith(".dm2")) {
SCR.BeginLoadingPlaque(); // for local system
SV_SEND.SV_BroadcastCommand("changing\n");
SV_SpawnServer(level, spawnpoint, ss_demo, attractloop, loadgame);
}
- else if (l > 4 && level.endsWith(".pcx"))
- {
+ else if (l > 4 && level.endsWith(".pcx")) {
SCR.BeginLoadingPlaque(); // for local system
SV_SEND.SV_BroadcastCommand("changing\n");
SV_SpawnServer(level, spawnpoint, ss_pic, attractloop, loadgame);
}
- else
- {
+ else {
SCR.BeginLoadingPlaque(); // for local system
SV_SEND.SV_BroadcastCommand("changing\n");
SV_SEND.SV_SendClientMessages();
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index 0764ce6..4fa3f45 100644
--- a/src/jake2/server/SV_SEND.java
+++ b/src/jake2/server/SV_SEND.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_SEND.java,v 1.3 2004-07-08 20:56:54 hzi Exp $
+// $Id: SV_SEND.java,v 1.4 2004-08-22 14:25:13 salomo Exp $
package jake2.server;
@@ -40,11 +40,11 @@ public class SV_SEND extends SV_MAIN {
=============================================================================
*/
- public static byte sv_outputbuf[] = new byte[SV_OUTPUTBUF_LENGTH];
+ public static byte sv_outputbuf[]= new byte[SV_OUTPUTBUF_LENGTH];
public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) {
if (sv_redirected == RD_PACKET) {
- String s = ("print\n" + outputbuf);
+ String s= ("print\n" + outputbuf);
Netchan.Netchan_OutOfBand(NS_SERVER, Netchan.net_from, s.length(), s.getBytes());
}
else if (sv_redirected == RD_CLIENT) {
@@ -103,23 +103,22 @@ public class SV_SEND extends SV_MAIN {
// va_end (argptr);
// echo to console
- if (dedicated.value!=0)
- {
-
- //char copy[1024];
- //int i;
-
- // mask off high bits
- //for (i=0 ; i<1023 && string[i] ; i++)
- //copy[i] = string[i]&127;
- //copy[i] = 0;
- //Com_Printf ("%s", copy);
-
- Com.Printf(s);
- }
+ if (dedicated.value != 0) {
+
+ //char copy[1024];
+ //int i;
+
+ // mask off high bits
+ //for (i=0 ; i<1023 && string[i] ; i++)
+ //copy[i] = string[i]&127;
+ //copy[i] = 0;
+ //Com_Printf ("%s", copy);
- for (int i = 0; i < SV_MAIN.maxclients.value; i++) {
- cl = SV_MAIN.svs.clients[i];
+ Com.Printf(s);
+ }
+
+ for (int i= 0; i < SV_MAIN.maxclients.value; i++) {
+ cl= SV_MAIN.svs.clients[i];
if (level < cl.messagelevel)
continue;
if (cl.state != cs_spawned)
@@ -173,15 +172,15 @@ public class SV_SEND extends SV_MAIN {
boolean reliable;
int area1, area2;
- reliable = false;
+ reliable= false;
if (to != MULTICAST_ALL_R && to != MULTICAST_ALL) {
- leafnum = CM.CM_PointLeafnum(origin);
- area1 = CM.CM_LeafArea(leafnum);
+ leafnum= CM.CM_PointLeafnum(origin);
+ area1= CM.CM_LeafArea(leafnum);
}
else {
- leafnum = 0; // just to avoid compiler warnings
- area1 = 0;
+ leafnum= 0; // just to avoid compiler warnings
+ area1= 0;
}
// if doing a serverrecord, store everything
@@ -190,36 +189,36 @@ public class SV_SEND extends SV_MAIN {
switch (to) {
case MULTICAST_ALL_R :
- reliable = true; // intentional fallthrough, no break here
+ reliable= true; // intentional fallthrough, no break here
case MULTICAST_ALL :
- leafnum = 0;
- mask = null;
+ leafnum= 0;
+ mask= null;
break;
case MULTICAST_PHS_R :
- reliable = true; // intentional fallthrough
+ reliable= true; // intentional fallthrough
case MULTICAST_PHS :
- leafnum = CM.CM_PointLeafnum(origin);
- cluster = CM.CM_LeafCluster(leafnum);
- mask = CM.CM_ClusterPHS(cluster);
+ leafnum= CM.CM_PointLeafnum(origin);
+ cluster= CM.CM_LeafCluster(leafnum);
+ mask= CM.CM_ClusterPHS(cluster);
break;
case MULTICAST_PVS_R :
- reliable = true; // intentional fallthrough
+ reliable= true; // intentional fallthrough
case MULTICAST_PVS :
- leafnum = CM.CM_PointLeafnum(origin);
- cluster = CM.CM_LeafCluster(leafnum);
- mask = CM.CM_ClusterPVS(cluster);
+ leafnum= CM.CM_PointLeafnum(origin);
+ cluster= CM.CM_LeafCluster(leafnum);
+ mask= CM.CM_ClusterPVS(cluster);
break;
default :
- mask = null;
+ mask= null;
Com.Error(ERR_FATAL, "SV_Multicast: bad to:" + to + "\n");
}
// send the data to all relevent clients
- for (j = 0; j < maxclients.value; j++) {
- client = svs.clients[j];
+ for (j= 0; j < maxclients.value; j++) {
+ client= svs.clients[j];
if (client.state == cs_free || client.state == cs_zombie)
continue;
@@ -227,12 +226,12 @@ public class SV_SEND extends SV_MAIN {
continue;
if (mask != null) {
- leafnum = CM.CM_PointLeafnum(client.edict.s.origin);
- cluster = CM.CM_LeafCluster(leafnum);
- area2 = CM.CM_LeafArea(leafnum);
+ leafnum= CM.CM_PointLeafnum(client.edict.s.origin);
+ cluster= CM.CM_LeafCluster(leafnum);
+ area2= CM.CM_LeafArea(leafnum);
if (!CM.CM_AreasConnected(area1, area2))
continue;
-
+
// quake2 bugfix
if (cluster == -1)
continue;
@@ -287,7 +286,7 @@ public class SV_SEND extends SV_MAIN {
int flags;
int i;
int ent;
- float[] origin_v = {0,0,0};
+ float[] origin_v= { 0, 0, 0 };
boolean use_phs;
if (volume < 0 || volume > 1.0)
@@ -302,21 +301,19 @@ public class SV_SEND extends SV_MAIN {
if (timeofs < 0 || timeofs > 0.255)
Com.Error(ERR_FATAL, "SV_StartSound: timeofs = " + timeofs);
- //ent = NUM_FOR_EDICT(entity);
- //TODO: somehow risky (dont know if constant correct index)
- ent = entity.index;
+ ent= entity.index;
- if ((channel & 8) != 0) // no PHS flag
- {
- use_phs = false;
+ // no PHS flag
+ if ((channel & 8) != 0) {
+ use_phs= false;
channel &= 7;
}
else
- use_phs = true;
+ use_phs= true;
- sendchan = (ent << 3) | (channel & 7);
+ sendchan= (ent << 3) | (channel & 7);
- flags = 0;
+ flags= 0;
if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME)
flags |= SND_VOLUME;
if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION)
@@ -335,10 +332,10 @@ public class SV_SEND extends SV_MAIN {
// use the entity origin unless it is a bmodel or explicitly specified
if (origin == null) {
- origin = origin_v;
+ origin= origin_v;
if (entity.solid == SOLID_BSP) {
- for (i = 0; i < 3; i++)
- origin_v[i] = entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]);
+ for (i= 0; i < 3; i++)
+ origin_v[i]= entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]);
}
else {
VectorCopy(entity.s.origin, origin_v);
@@ -365,7 +362,7 @@ public class SV_SEND extends SV_MAIN {
// if the sound doesn't attenuate,send it to everyone
// (global radio chatter, voiceovers, etc)
if (attenuation == ATTN_NONE)
- use_phs = false;
+ use_phs= false;
if ((channel & CHAN_RELIABLE) != 0) {
if (use_phs)
@@ -395,17 +392,17 @@ public class SV_SEND extends SV_MAIN {
=======================
*/
public static boolean SV_SendClientDatagram(client_t client) {
- byte msg_buf[] = new byte[MAX_MSGLEN];
- sizebuf_t msg = new sizebuf_t();
+ byte msg_buf[]= new byte[MAX_MSGLEN];
+ sizebuf_t msg= new sizebuf_t();
SV_ENTS.SV_BuildClientFrame(client);
SZ.Init(msg, msg_buf, msg_buf.length);
- msg.allowoverflow = true;
+ msg.allowoverflow= true;
// send over all the relevant entity_state_t
// and the player_state_t
- SV_CCMDS.SV_WriteFrameToClient (client, msg);
+ SV_CCMDS.SV_WriteFrameToClient(client, msg);
// copy the accumulated multicast datagram
// for this client out to the message
@@ -426,7 +423,7 @@ public class SV_SEND extends SV_MAIN {
Netchan.Transmit(client.netchan, msg.cursize, msg.data);
// record the size for rate estimation
- client.message_size[sv.framenum % RATE_MESSAGES] = msg.cursize;
+ client.message_size[sv.framenum % RATE_MESSAGES]= msg.cursize;
return true;
}
@@ -444,7 +441,7 @@ public class SV_SEND extends SV_MAIN {
catch (IOException e) {
Com.Printf("IOError closing d9emo fiele:" + e);
}
- sv.demofile = null;
+ sv.demofile= null;
}
SV_ENTS.SV_Nextserver();
}
@@ -465,15 +462,15 @@ public class SV_SEND extends SV_MAIN {
if (c.netchan.remote_address.type == NA_LOOPBACK)
return false;
- total = 0;
+ total= 0;
- for (i = 0; i < RATE_MESSAGES; i++) {
+ for (i= 0; i < RATE_MESSAGES; i++) {
total += c.message_size[i];
}
if (total > c.rate) {
c.surpressCount++;
- c.message_size[sv.framenum % RATE_MESSAGES] = 0;
+ c.message_size[sv.framenum % RATE_MESSAGES]= 0;
return true;
}
@@ -489,20 +486,20 @@ public class SV_SEND extends SV_MAIN {
int i;
client_t c;
int msglen;
- byte msgbuf[] = new byte[MAX_MSGLEN];
+ byte msgbuf[]= new byte[MAX_MSGLEN];
int r;
- msglen = 0;
+ msglen= 0;
// read the next demo message if needed
if (sv.state == ss_demo && sv.demofile != null) {
if (sv_paused.value != 0)
- msglen = 0;
+ msglen= 0;
else {
// get the next message
//r = fread (&msglen, 4, 1, sv.demofile);
try {
- msglen = EndianHandler.swapInt(sv.demofile.readInt());
+ msglen= EndianHandler.swapInt(sv.demofile.readInt());
}
catch (Exception e) {
SV_DemoCompleted();
@@ -518,9 +515,9 @@ public class SV_SEND extends SV_MAIN {
Com.Error(ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN");
//r = fread (msgbuf, msglen, 1, sv.demofile);
- r = 0;
+ r= 0;
try {
- r = sv.demofile.read(msgbuf, 0, msglen);
+ r= sv.demofile.read(msgbuf, 0, msglen);
}
catch (IOException e1) {
Com.Printf("IOError: reading demo file, " + e1);
@@ -533,8 +530,8 @@ public class SV_SEND extends SV_MAIN {
}
// send a message to each connected client
- for (i = 0; i < maxclients.value; i++) {
- c = svs.clients[i];
+ for (i= 0; i < maxclients.value; i++) {
+ c= svs.clients[i];
if (c.state == 0)
continue;
diff --git a/src/jake2/server/client_t.java b/src/jake2/server/client_t.java
index 2bbadf9..b8ccf0e 100644
--- a/src/jake2/server/client_t.java
+++ b/src/jake2/server/client_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 13.01.2004 by RST.
-// $Id: client_t.java,v 1.1 2004-07-07 19:59:50 hzi Exp $
+// $Id: client_t.java,v 1.2 2004-08-22 14:25:13 salomo Exp $
package jake2.server;
@@ -43,7 +43,6 @@ public class client_t {
int state;
- //char userinfo[MAX_INFO_STRING]; // name, etc
String userinfo = "";
int lastframe; // for delta compression
@@ -85,6 +84,6 @@ public class client_t {
netchan_t netchan = new netchan_t();
- //TODO: this was introduced by rst, since java can't calculate the index out of the address.
+ //this was introduced by rst, since java can't calculate the index out of the address.
int serverindex;
}