summaryrefslogtreecommitdiffstats
path: root/src/jake2/server
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/server
parent93a1cb6d6bfa9d7a80c004100125c829f1f36e86 (diff)
cleanups and base3 bugfix for the load and save routines.
Diffstat (limited to 'src/jake2/server')
-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
6 files changed, 271 insertions, 496 deletions
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;
}