aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/server
diff options
context:
space:
mode:
authorRene Stoeckel <[email protected]>2005-12-27 21:02:31 +0000
committerRene Stoeckel <[email protected]>2005-12-27 21:02:31 +0000
commit9d4a45835aa0ecdf6c92c3cc1ac93e3526ba40e9 (patch)
treeb0dc541e86f11ef2990bac8f362cb6971caec170 /src/jake2/server
parent90135445c8833ff11a31bf37fa09a0b265904b55 (diff)
code cleanups and beautification
Diffstat (limited to 'src/jake2/server')
-rw-r--r--src/jake2/server/SV_ENTS.java57
-rw-r--r--src/jake2/server/SV_MAIN.java204
2 files changed, 101 insertions, 160 deletions
diff --git a/src/jake2/server/SV_ENTS.java b/src/jake2/server/SV_ENTS.java
index 6f4ca0f..0f32322 100644
--- a/src/jake2/server/SV_ENTS.java
+++ b/src/jake2/server/SV_ENTS.java
@@ -19,7 +19,9 @@
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_ENTS.java,v 1.6 2005-12-03 19:46:17 salomo Exp $
+
+// $Id: SV_ENTS.java,v 1.7 2005-12-27 21:02:30 salomo Exp $
+
package jake2.server;
import jake2.Defines;
@@ -31,7 +33,7 @@ import java.io.IOException;
public class SV_ENTS {
- /*
+ /**
* =============================================================================
*
* Build a client frame structure
@@ -49,11 +51,8 @@ public class SV_ENTS {
* =============================================================================
*/
- /*
- * ============= SV_EmitPacketEntities
- *
+ /**
* Writes a delta update of an entity_state_t list to the message.
- * =============
*/
static void SV_EmitPacketEntities(client_frame_t from, client_frame_t to,
sizebuf_t msg) {
@@ -89,11 +88,11 @@ public class SV_ENTS {
oldnum = oldent.number;
}
- if (newnum == oldnum) { // delta update from old position
+ if (newnum == oldnum) {
+ // delta update from old position
// because the force parm is false, this will not result
// in any bytes being emited if the entity has not changed at
- // all
- // note that players are always 'newentities', this updates
+ // all note that players are always 'newentities', this updates
// their oldorigin always
// and prevents warping
MSG.WriteDeltaEntity(oldent, newent, msg, false,
@@ -103,16 +102,16 @@ public class SV_ENTS {
continue;
}
- if (newnum < oldnum) { // this is a new entity, send it from the
- // baseline
+ if (newnum < oldnum) {
+ // this is a new entity, send it from the baseline
MSG.WriteDeltaEntity(SV_INIT.sv.baselines[newnum], newent, msg,
true, true);
newindex++;
continue;
}
- if (newnum > oldnum) { // the old entity isn't present in the new
- // message
+ if (newnum > oldnum) {
+ // the old entity isn't present in the new message
bits = Defines.U_REMOVE;
if (oldnum >= 256)
bits |= Defines.U_NUMBER16 | Defines.U_MOREBITS1;
@@ -135,10 +134,8 @@ public class SV_ENTS {
}
- /*
- * ============= SV_WritePlayerstateToClient
- *
- * =============
+ /**
+ * Writes the status of a player to a client system.
*/
static void SV_WritePlayerstateToClient(client_frame_t from,
client_frame_t to, sizebuf_t msg) {
@@ -158,9 +155,7 @@ public class SV_ENTS {
} else
ops = from.ps;
- //
// determine what needs to be sent
- //
pflags = 0;
if (ps.pmove.pm_type != ops.pmove.pm_type)
@@ -220,15 +215,11 @@ public class SV_ENTS {
pflags |= Defines.PS_WEAPONINDEX;
- //
// write it
- //
MSG.WriteByte(msg, Defines.svc_playerinfo);
MSG.WriteShort(msg, pflags);
- //
// write the pmove_state_t
- //
if ((pflags & Defines.PS_M_TYPE) != 0)
MSG.WriteByte(msg, ps.pmove.pm_type);
@@ -259,9 +250,7 @@ public class SV_ENTS {
MSG.WriteShort(msg, ps.pmove.delta_angles[2]);
}
- //
// write the rest of the player_state_t
- //
if ((pflags & Defines.PS_VIEWOFFSET) != 0) {
MSG.WriteChar(msg, ps.viewoffset[0] * 4);
MSG.WriteChar(msg, ps.viewoffset[1] * 4);
@@ -316,8 +305,8 @@ public class SV_ENTS {
MSG.WriteShort(msg, ps.stats[i]);
}
- /*
- * ================== SV_WriteFrameToClient ==================
+ /**
+ * Writes a frame to a client system.
*/
public static void SV_WriteFrameToClient(client_t client, sizebuf_t msg) {
//ptr
@@ -359,8 +348,10 @@ public class SV_ENTS {
SV_EmitPacketEntities(oldframe, frame, msg);
}
- /** The client will interpolate the view position, so we can't use a single
- * PVS point. */
+ /**
+ * The client will interpolate the view position, so we can't use a single
+ * PVS point.
+ */
public static void SV_FatPVS(float[] org) {
int leafs[] = new int[64];
int i, j, count;
@@ -472,7 +463,7 @@ public class SV_ENTS {
continue;
// ignore if not touching a PV leaf
- // check area
+ // check area
if (ent != clent) {
if (!CM.CM_AreasConnected(clientarea, ent.areanum)) {
// doors can legally straddle two areas, so we may need to check another one
@@ -543,11 +534,9 @@ public class SV_ENTS {
}
}
- /*
- * ================== SV_RecordDemoMessage
- *
+ /**
* Save everything in the world out without deltas. Used for recording
- * footage for merged or assembled demos ==================
+ * footage for merged or assembled demos.
*/
public static void SV_RecordDemoMessage() {
int e;
diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java
index e9b876e..e325aef 100644
--- a/src/jake2/server/SV_MAIN.java
+++ b/src/jake2/server/SV_MAIN.java
@@ -19,7 +19,7 @@
*/
// Created on 13.01.2004 by RST.
-// $Id: SV_MAIN.java,v 1.14 2005-12-18 22:10:13 cawe Exp $
+// $Id: SV_MAIN.java,v 1.15 2005-12-27 21:02:30 salomo Exp $
package jake2.server;
import jake2.Defines;
@@ -34,10 +34,11 @@ import java.io.IOException;
public class SV_MAIN {
- public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS]; // address
- // of
- // group
- // servers
+ /** Addess of group servers.*/
+ public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS];
+
+
+
static {
for (int i = 0; i < Defines.MAX_MASTERS; i++) {
master_adr[i] = new netadr_t();
@@ -85,24 +86,16 @@ public class SV_MAIN {
public static cvar_t sv_reconnect_limit; // minimum seconds between connect
// messages
- //============================================================================
-
- /*
- * ================ Master_Heartbeat
- *
+ /**
* Send a message to the master every few minutes to let it know we are
- * alive, and log information ================
+ * alive, and log information.
*/
public static final int HEARTBEAT_SECONDS = 300;
- //============================================================================
-
- /*
- * ===================== SV_DropClient
- *
+ /**
* Called when the player is totally leaving the server, either willingly or
* unwillingly. This is NOT called if the entire server is quiting or
- * crashing. =====================
+ * crashing.
*/
public static void SV_DropClient(client_t drop) {
// add the disconnect
@@ -123,19 +116,15 @@ public class SV_MAIN {
drop.name = "";
}
- /*
- * ==============================================================================
+
+ /* ==============================================================================
*
* CONNECTIONLESS COMMANDS
*
- * ==============================================================================
- */
-
- /*
- * =============== SV_StatusString
- *
- * Builds the string that is sent as heartbeats and status replies
- * ===============
+ * ==============================================================================*/
+
+ /**
+ * Builds the string that is sent as heartbeats and status replies.
*/
public static String SV_StatusString() {
String player;
@@ -167,31 +156,25 @@ public class SV_MAIN {
return status;
}
- /*
- * ================ SVC_Status
- *
- * Responds with all the info that qplug or qspy can see ================
+ /**
+ * Responds with all the info that qplug or qspy can see
*/
public static void SVC_Status() {
Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "print\n"
+ SV_StatusString());
}
- /*
- * ================ SVC_Ack
- *
- * ================
+ /**
+ * SVC_Ack
*/
public static void SVC_Ack() {
Com.Printf("Ping acknowledge from " + NET.AdrToString(Globals.net_from)
+ "\n");
}
- /*
- * ================ SVC_Info
- *
- * Responds with short info for broadcast scans The second parameter should
- * be the current protocol version number. ================
+ /**
+ * SVC_Info, responds with short info for broadcast scans The second parameter should
+ * be the current protocol version number.
*/
public static void SVC_Info() {
String string;
@@ -219,22 +202,18 @@ public class SV_MAIN {
+ string);
}
- /*
- * ================ SVC_Ping
- *
- * Just responds with an acknowledgement ================
+ /**
+ * SVC_Ping, Just responds with an acknowledgement.
*/
public static void SVC_Ping() {
Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "ack");
}
- /*
- * ================= SVC_GetChallenge
- *
+ /**
* Returns a challenge number that can be used in a subsequent
* client_connect command. We do this to prevent denial of service attacks
* that flood the server with invalid connection IPs. With a challenge, they
- * must give a valid IP address. =================
+ * must give a valid IP address.
*/
public static void SVC_GetChallenge() {
int i;
@@ -268,10 +247,8 @@ public class SV_MAIN {
"challenge " + SV_INIT.svs.challenges[i].challenge);
}
- /*
- * ================== SVC_DirectConnect
- *
- * A connection request that did not come from the master ==================
+ /**
+ * A connection request that did not come from the master.
*/
public static void SVC_DirectConnect() {
String userinfo;
@@ -279,8 +256,6 @@ public class SV_MAIN {
int i;
client_t cl;
- edict_t ent;
- int edictnum;
int version;
int qport;
@@ -300,11 +275,8 @@ public class SV_MAIN {
int challenge = Lib.atoi(Cmd.Argv(3));
userinfo = Cmd.Argv(4);
- //userinfo[sizeof(userinfo) - 1] = 0;
-
// force the IP key/value pair so the game can filter based on ip
- userinfo = Info.Info_SetValueForKey1(userinfo, "ip", NET
- .AdrToString(Globals.net_from));
+ userinfo = Info.Info_SetValueForKey(userinfo, "ip", NET.AdrToString(Globals.net_from));
// attractloop servers are ONLY for local clients
if (SV_INIT.sv.attractloop) {
@@ -375,20 +347,26 @@ public class SV_MAIN {
gotnewcl(index, challenge, userinfo, adr, qport);
}
+ /**
+ * Initializes player structures after successfull connection.
+ */
public static void gotnewcl(int i, int challenge, String userinfo,
netadr_t adr, int qport) {
// build a new connection
// accept the new client
// this is the only place a client_t is ever initialized
- //*newcl = temp;
SV_MAIN.sv_client = SV_INIT.svs.clients[i];
- //edictnum = (newcl-svs.clients)+1;
+
int edictnum = i + 1;
+
edict_t ent = GameBase.g_edicts[edictnum];
SV_INIT.svs.clients[i].edict = ent;
- SV_INIT.svs.clients[i].challenge = challenge; // save challenge for
- // checksumming
+
+ // save challenge for checksumming
+ SV_INIT.svs.clients[i].challenge = challenge;
+
+
// get the game a chance to reject this connection or modify the
// userinfo
@@ -411,21 +389,24 @@ public class SV_MAIN {
// send the connect packet to the client
Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "client_connect");
- Netchan.Setup(Defines.NS_SERVER, SV_INIT.svs.clients[i].netchan, adr,
- qport);
+ Netchan.Setup(Defines.NS_SERVER, SV_INIT.svs.clients[i].netchan, adr, qport);
SV_INIT.svs.clients[i].state = Defines.cs_connected;
SZ.Init(SV_INIT.svs.clients[i].datagram,
SV_INIT.svs.clients[i].datagram_buf,
SV_INIT.svs.clients[i].datagram_buf.length);
+
SV_INIT.svs.clients[i].datagram.allowoverflow = true;
- SV_INIT.svs.clients[i].lastmessage = SV_INIT.svs.realtime; // don't
- // timeout
+ SV_INIT.svs.clients[i].lastmessage = SV_INIT.svs.realtime; // don't timeout
SV_INIT.svs.clients[i].lastconnect = SV_INIT.svs.realtime;
Com.DPrintf("new client added.\n");
}
+
+ /**
+ * Checks if the rcon password is corect.
+ */
public static int Rcon_Validate() {
if (0 == SV_MAIN.rcon_password.string.length())
return 0;
@@ -478,12 +459,10 @@ public class SV_MAIN {
Com.EndRedirect();
}
- /*
- * ================= SV_ConnectionlessPacket
- *
+ /**
* A connectionless packet has four leading 0xff characters to distinguish
* it from a game channel. Clients that are in the game can still send
- * connectionless packets. =================
+ * connectionless packets. It is used also by rcon commands.
*/
public static void SV_ConnectionlessPacket() {
String s;
@@ -497,8 +476,9 @@ public class SV_MAIN {
Cmd.TokenizeString(s.toCharArray(), false);
c = Cmd.Argv(0);
- //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c
- // + "\n");
+
+ //for debugging purposes
+ //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c + "\n");
//Com.Printf(Lib.hexDump(net_message.data, 64, false) + "\n");
if (0 == Lib.strcmp(c, "ping"))
@@ -523,12 +503,8 @@ public class SV_MAIN {
}
}
- //============================================================================
-
- /*
- * =================== SV_CalcPings
- *
- * Updates the cl.ping variables ===================
+ /**
+ * Updates the cl.ping variables.
*/
public static void SV_CalcPings() {
int i, j;
@@ -558,12 +534,9 @@ public class SV_MAIN {
}
}
- /*
- * =================== SV_GiveMsec
- *
+ /**
* Every few frames, gives all clients an allotment of milliseconds for
* their command moves. If they exceed it, assume cheating.
- * ===================
*/
public static void SV_GiveMsec() {
int i;
@@ -581,8 +554,8 @@ public class SV_MAIN {
}
}
- /*
- * ================= SV_ReadPackets =================
+ /**
+ * Reads packets from the network or loopback.
*/
public static void SV_ReadPackets() {
int i;
@@ -638,16 +611,14 @@ public class SV_MAIN {
}
}
- /*
- * ================== SV_CheckTimeouts
- *
+ /**
* If a packet has not been received from a client for timeout.value
* seconds, drop the conneciton. Server frames are used instead of realtime
* to avoid dropping the local client while debugging.
*
* When a client is normally dropped, the client_t goes into a zombie state
* for a few seconds to make sure any final reliable message gets resent if
- * necessary ==================
+ * necessary.
*/
public static void SV_CheckTimeouts() {
int i;
@@ -678,11 +649,11 @@ public class SV_MAIN {
}
}
- /*
- * ================ SV_PrepWorldFrame
+ /**
+ * SV_PrepWorldFrame
*
* This has to be done before the world logic, because player processing
- * happens outside RunWorldFrame ================
+ * happens outside RunWorldFrame.
*/
public static void SV_PrepWorldFrame() {
edict_t ent;
@@ -696,8 +667,8 @@ public class SV_MAIN {
}
- /*
- * ================= SV_RunGameFrame =================
+ /**
+ * SV_RunGameFrame.
*/
public static void SV_RunGameFrame() {
if (Globals.host_speeds.value != 0)
@@ -727,10 +698,8 @@ public class SV_MAIN {
}
- /*
- * ================== SV_Frame
- *
- * ==================
+ /**
+ * SV_Frame.
*/
public static void SV_Frame(long msec) {
Globals.time_before_game = Globals.time_after_game = 0;
@@ -767,11 +736,9 @@ public class SV_MAIN {
}
// update ping based on the last known frame from all clients
- //TODO: dont need yet
SV_CalcPings();
// give the clients some timeslices
- //TODO: dont need yet
SV_GiveMsec();
// let everything in the world think and move
@@ -781,11 +748,9 @@ public class SV_MAIN {
SV_SEND.SV_SendClientMessages();
// save the entire world state if recording a serverdemo
- //TODO: dont need yet
- //SV_WORLD.SV_RecordDemoMessage();
+ SV_ENTS.SV_RecordDemoMessage();
// send a heartbeat to the master if needed
- //TODO: dont need yet
Master_Heartbeat();
// clear teleport flags, etc for next frame
@@ -826,11 +791,10 @@ public class SV_MAIN {
SV_MAIN.master_adr[i], "heartbeat\n" + string);
}
}
+
- /*
- * ================= Master_Shutdown
- *
- * Informs all masters that this server is going down =================
+ /**
+ * Master_Shutdown, Informs all masters that this server is going down.
*/
public static void Master_Shutdown() {
int i;
@@ -853,14 +817,11 @@ public class SV_MAIN {
SV_MAIN.master_adr[i], "shutdown");
}
}
+
- //============================================================================
-
- /*
- * ================= SV_UserinfoChanged
- *
+ /**
* Pull specific info from a newly changed userinfo string into a more C
- * freindly form. =================
+ * freindly form.
*/
public static void SV_UserinfoChanged(client_t cl) {
String val;
@@ -897,11 +858,7 @@ public class SV_MAIN {
}
- //============================================================================
-
- /*
- * =============== SV_Init
- *
+ /**
* Only called at quake2.exe startup, not for each game ===============
*/
public static void SV_Init() {
@@ -952,13 +909,11 @@ public class SV_MAIN {
Globals.net_message_buffer.length);
}
- /*
- * ================== SV_FinalMessage
- *
+ /**
* Used by SV_Shutdown to send a final message to all connected clients
* before the server goes down. The messages are sent immediately, not just
* stuck on the outgoing message list, because the server is going to
- * totally exit after returning from this function. ==================
+ * totally exit after returning from this function.
*/
public static void SV_FinalMessage(String message, boolean reconnect) {
int i;
@@ -991,11 +946,8 @@ public class SV_MAIN {
}
}
- /*
- * ================ SV_Shutdown
- *
- * Called when each game quits, before Sys_Quit or Sys_Error
- * ================
+ /**
+ * Called when each game quits, before Sys_Quit or Sys_Error.
*/
public static void SV_Shutdown(String finalmsg, boolean reconnect) {
if (SV_INIT.svs.clients != null)