aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/server
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-09-06 19:39:21 +0000
committerHolger Zickner <[email protected]>2004-09-06 19:39:21 +0000
commit8f144736583c3b4bc4e6334ab96324094444c595 (patch)
treeaaf2b9fbd0c9afeceb2b389672981b2878ce31a3 /src/jake2/server
parent5483a5627904f143a3e2e00c96f7db6a188d1ec0 (diff)
merge changes for 0.9.3
Diffstat (limited to 'src/jake2/server')
-rw-r--r--src/jake2/server/SV.java933
-rw-r--r--src/jake2/server/SV_CCMDS.java430
-rw-r--r--src/jake2/server/SV_ENTS.java22
-rw-r--r--src/jake2/server/SV_GAME.java56
-rw-r--r--src/jake2/server/SV_INIT.java219
-rw-r--r--src/jake2/server/SV_MAIN.java23
-rw-r--r--src/jake2/server/SV_SEND.java143
-rw-r--r--src/jake2/server/SV_USER.java10
-rw-r--r--src/jake2/server/SV_WORLD.java28
-rw-r--r--src/jake2/server/client_t.java5
-rw-r--r--src/jake2/server/scrap.jpage24
11 files changed, 937 insertions, 956 deletions
diff --git a/src/jake2/server/SV.java b/src/jake2/server/SV.java
index def4112..39dc0ec 100644
--- a/src/jake2/server/SV.java
+++ b/src/jake2/server/SV.java
@@ -2,9 +2,9 @@
* SV.java
* Copyright (C) 2003
*
- * $Id: SV.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
+ * $Id: SV.java,v 1.2.2.1 2004-09-06 19:39:18 hzi Exp $
*/
- /*
+/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or
@@ -25,209 +25,228 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.server;
-import jake2.*;
+import jake2.Defines;
+import jake2.client.M;
import jake2.game.*;
import jake2.qcommon.Com;
-import jake2.util.*;
-import jake2.client.*;
-import jake2.game.*;
-import jake2.game.trace_t;
+import jake2.util.Lib;
+import jake2.util.Math3D;
/**
* SV
*/
-public final class SV {
+public final class SV
+{
//file_io
//=====================================================================
//g_phys
-
+
///////////////////////////////////////
- public static edict_t[] SV_TestEntityPosition(edict_t ent) {
+ public static edict_t[] SV_TestEntityPosition(edict_t ent)
+ {
trace_t trace;
int mask;
-
+
if (ent.clipmask != 0)
- mask = ent.clipmask;
+ mask= ent.clipmask;
else
- mask = Defines.MASK_SOLID;
-
- trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, ent.s.origin, ent, mask);
-
+ mask= Defines.MASK_SOLID;
+
+ trace= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, ent.s.origin, ent, mask);
+
if (trace.startsolid)
return GameBase.g_edicts;
-
+
return null;
}
///////////////////////////////////////
- public static void SV_CheckVelocity(edict_t ent) {
+ public static void SV_CheckVelocity(edict_t ent)
+ {
int i;
-
+
//
// bound velocity
//
- for (i = 0; i < 3; i++) {
+ for (i= 0; i < 3; i++)
+ {
if (ent.velocity[i] > GameBase.sv_maxvelocity.value)
- ent.velocity[i] = GameBase.sv_maxvelocity.value;
+ ent.velocity[i]= GameBase.sv_maxvelocity.value;
else if (ent.velocity[i] < -GameBase.sv_maxvelocity.value)
- ent.velocity[i] = -GameBase.sv_maxvelocity.value;
+ ent.velocity[i]= -GameBase.sv_maxvelocity.value;
}
}
/**
* Runs thinking code for this frame if necessary.
*/
- public static boolean SV_RunThink(edict_t ent) {
+ public static boolean SV_RunThink(edict_t ent)
+ {
float thinktime;
-
- thinktime = ent.nextthink;
+
+ thinktime= ent.nextthink;
if (thinktime <= 0)
return true;
if (thinktime > GameBase.level.time + 0.001)
return true;
-
- ent.nextthink = 0;
-
+
+ ent.nextthink= 0;
+
if (ent.think == null)
- GameBase.gi.error("NULL ent.think");
+ Com.Error(Defines.ERR_FATAL, "NULL ent.think");
ent.think.think(ent);
-
+
return false;
}
/**
* Two entities have touched, so run their touch functions.
*/
- public static void SV_Impact(edict_t e1, trace_t trace) {
+ public static void SV_Impact(edict_t e1, trace_t trace)
+ {
edict_t e2;
- // cplane_t backplane;
-
- e2 = trace.ent;
-
+
+ e2= trace.ent;
+
if (e1.touch != null && e1.solid != Defines.SOLID_NOT)
e1.touch.touch(e1, e2, trace.plane, trace.surface);
-
+
if (e2.touch != null && e2.solid != Defines.SOLID_NOT)
- e2.touch.touch(e2, e1, null, null);
+ e2.touch.touch(e2, e1, GameBase.dummyplane, null);
}
- public static int SV_FlyMove(edict_t ent, float time, int mask) {
+ public static int SV_FlyMove(edict_t ent, float time, int mask)
+ {
edict_t hit;
int bumpcount, numbumps;
- float[] dir = { 0.0f, 0.0f, 0.0f };
+ float[] dir= { 0.0f, 0.0f, 0.0f };
float d;
int numplanes;
- float[][] planes = new float[GameBase.MAX_CLIP_PLANES][3];
- float[] primal_velocity = { 0.0f, 0.0f, 0.0f };
- float[] original_velocity = { 0.0f, 0.0f, 0.0f };
- float[] new_velocity = { 0.0f, 0.0f, 0.0f };
+ float[][] planes= new float[GameBase.MAX_CLIP_PLANES][3];
+ float[] primal_velocity= { 0.0f, 0.0f, 0.0f };
+ float[] original_velocity= { 0.0f, 0.0f, 0.0f };
+ float[] new_velocity= { 0.0f, 0.0f, 0.0f };
int i, j;
trace_t trace;
- float[] end = { 0.0f, 0.0f, 0.0f };
+ float[] end= { 0.0f, 0.0f, 0.0f };
float time_left;
int blocked;
-
- numbumps = 4;
-
- blocked = 0;
+
+ numbumps= 4;
+
+ blocked= 0;
Math3D.VectorCopy(ent.velocity, original_velocity);
Math3D.VectorCopy(ent.velocity, primal_velocity);
- numplanes = 0;
-
- time_left = time;
-
- ent.groundentity = null;
- for (bumpcount = 0; bumpcount < numbumps; bumpcount++) {
- for (i = 0; i < 3; i++)
- end[i] = ent.s.origin[i] + time_left * ent.velocity[i];
-
- trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, end, ent, mask);
-
- if (trace.allsolid) { // entity is trapped in another solid
+ numplanes= 0;
+
+ time_left= time;
+
+ ent.groundentity= null;
+ for (bumpcount= 0; bumpcount < numbumps; bumpcount++)
+ {
+ for (i= 0; i < 3; i++)
+ end[i]= ent.s.origin[i] + time_left * ent.velocity[i];
+
+ trace= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, end, ent, mask);
+
+ if (trace.allsolid)
+ { // entity is trapped in another solid
Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity);
return 3;
}
-
- if (trace.fraction > 0) { // actually covered some distance
+
+ if (trace.fraction > 0)
+ { // actually covered some distance
Math3D.VectorCopy(trace.endpos, ent.s.origin);
Math3D.VectorCopy(ent.velocity, original_velocity);
- numplanes = 0;
+ numplanes= 0;
}
-
+
if (trace.fraction == 1)
break; // moved the entire distance
-
- hit = trace.ent;
-
- if (trace.plane.normal[2] > 0.7) {
+
+ hit= trace.ent;
+
+ if (trace.plane.normal[2] > 0.7)
+ {
blocked |= 1; // floor
- if (hit.solid == Defines.SOLID_BSP) {
- ent.groundentity = hit;
- ent.groundentity_linkcount = hit.linkcount;
+ if (hit.solid == Defines.SOLID_BSP)
+ {
+ ent.groundentity= hit;
+ ent.groundentity_linkcount= hit.linkcount;
}
}
- if (trace.plane.normal[2] == 0.0f) {
+ if (trace.plane.normal[2] == 0.0f)
+ {
blocked |= 2; // step
}
-
+
//
// run the impact function
//
SV_Impact(ent, trace);
if (!ent.inuse)
break; // removed by the impact function
-
+
time_left -= time_left * trace.fraction;
-
+
// cliped to another plane
- if (numplanes >= GameBase.MAX_CLIP_PLANES) { // this shouldn't really happen
+ if (numplanes >= GameBase.MAX_CLIP_PLANES)
+ { // this shouldn't really happen
Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity);
return 3;
}
-
+
Math3D.VectorCopy(trace.plane.normal, planes[numplanes]);
numplanes++;
-
+
//
// modify original_velocity so it parallels all of the clip planes
//
- for (i = 0; i < numplanes; i++) {
+ for (i= 0; i < numplanes; i++)
+ {
GameBase.ClipVelocity(original_velocity, planes[i], new_velocity, 1);
-
- for (j = 0; j < numplanes; j++)
- if ((j != i) && Math3D.VectorCompare(planes[i], planes[j]) == 0.0f) {
+
+ for (j= 0; j < numplanes; j++)
+ if ((j != i) && Math3D.VectorCompare(planes[i], planes[j]) == 0.0f)
+ {
if (Math3D.DotProduct(new_velocity, planes[j]) < 0)
break; // not ok
}
if (j == numplanes)
break;
}
-
- if (i != numplanes) { // go along this plane
+
+ if (i != numplanes)
+ { // go along this plane
Math3D.VectorCopy(new_velocity, ent.velocity);
- } else { // go along the crease
- if (numplanes != 2) {
+ }
+ else
+ { // go along the crease
+ if (numplanes != 2)
+ {
// gi.dprintf ("clip velocity, numplanes == %i\n",numplanes);
Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity);
return 7;
}
Math3D.CrossProduct(planes[0], planes[1], dir);
- d = Math3D.DotProduct(dir, ent.velocity);
+ d= Math3D.DotProduct(dir, ent.velocity);
Math3D.VectorScale(dir, d, ent.velocity);
}
-
+
//
// if original velocity is against the original velocity, stop dead
// to avoid tiny occilations in sloping corners
//
- if (Math3D.DotProduct(ent.velocity, primal_velocity) <= 0) {
+ if (Math3D.DotProduct(ent.velocity, primal_velocity) <= 0)
+ {
Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity);
return blocked;
}
}
-
+
return blocked;
}
@@ -237,55 +256,61 @@ public final class SV {
============
*/
- public static void SV_AddGravity(edict_t ent) {
+ public static void SV_AddGravity(edict_t ent)
+ {
ent.velocity[2] -= ent.gravity * GameBase.sv_gravity.value * Defines.FRAMETIME;
}
/**
* Does not change the entities velocity at all
*/
- public static trace_t SV_PushEntity(edict_t ent, float[] push) {
+ public static trace_t SV_PushEntity(edict_t ent, float[] push)
+ {
trace_t trace;
- float[] start = { 0, 0, 0 };
- float[] end = { 0, 0, 0 };
+ float[] start= { 0, 0, 0 };
+ float[] end= { 0, 0, 0 };
int mask;
-
+
Math3D.VectorCopy(ent.s.origin, start);
Math3D.VectorAdd(start, push, end);
-
+
// FIXME: test this
// a goto statement was replaced.
- boolean retry;
-
- do {
+ boolean retry= false;
+
+ do
+ {
if (ent.clipmask != 0)
- mask = ent.clipmask;
+ mask= ent.clipmask;
else
- mask = Defines.MASK_SOLID;
-
- trace = GameBase.gi.trace(start, ent.mins, ent.maxs, end, ent, mask);
-
+ mask= Defines.MASK_SOLID;
+
+ trace= GameBase.gi.trace(start, ent.mins, ent.maxs, end, ent, mask);
+
Math3D.VectorCopy(trace.endpos, ent.s.origin);
GameBase.gi.linkentity(ent);
-
- retry = false;
- if (trace.fraction != 1.0) {
+
+ retry= false;
+ if (trace.fraction != 1.0)
+ {
SV_Impact(ent, trace);
-
+
// if the pushed entity went away and the pusher is still there
- if (!trace.ent.inuse && ent.inuse) {
+ if (!trace.ent.inuse && ent.inuse)
+ {
// move the pusher back and try again
Math3D.VectorCopy(start, ent.s.origin);
GameBase.gi.linkentity(ent);
//goto retry;
- retry = true;
+ retry= true;
}
}
- } while (retry);
-
+ }
+ while (retry);
+
if (ent.inuse)
GameBase.G_TouchTriggers(ent);
-
+
return trace;
}
@@ -297,61 +322,65 @@ public final class SV {
otherwise riders would continue to slide.
============
*/
- public static boolean SV_Push(edict_t pusher, float[] move, float[] amove) {
+ public static boolean SV_Push(edict_t pusher, float[] move, float[] amove)
+ {
int i, e;
edict_t check, block[];
- float[] mins = { 0, 0, 0 };
- float[] maxs = { 0, 0, 0 };
+ float[] mins= { 0, 0, 0 };
+ float[] maxs= { 0, 0, 0 };
pushed_t p;
- float[] org = { 0, 0, 0 };
- float[] org2 = { 0, 0, 0 };
- float[] move2 = { 0, 0, 0 };
- float[] forward = { 0, 0, 0 };
- float[] right = { 0, 0, 0 };
- float[] up = { 0, 0, 0 };
-
+ float[] org= { 0, 0, 0 };
+ float[] org2= { 0, 0, 0 };
+ float[] move2= { 0, 0, 0 };
+ float[] forward= { 0, 0, 0 };
+ float[] right= { 0, 0, 0 };
+ float[] up= { 0, 0, 0 };
+
// clamp the move to 1/8 units, so the position will
// be accurate for client side prediction
- for (i = 0; i < 3; i++) {
+ for (i= 0; i < 3; i++)
+ {
float temp;
- temp = move[i] * 8.0f;
+ temp= move[i] * 8.0f;
if (temp > 0.0)
temp += 0.5;
else
temp -= 0.5;
- move[i] = 0.125f * (int) temp;
+ move[i]= 0.125f * (int) temp;
}
-
+
// find the bounding box
- for (i = 0; i < 3; i++) {
- mins[i] = pusher.absmin[i] + move[i];
- maxs[i] = pusher.absmax[i] + move[i];
+ for (i= 0; i < 3; i++)
+ {
+ mins[i]= pusher.absmin[i] + move[i];
+ maxs[i]= pusher.absmax[i] + move[i];
}
-
+
// we need this for pushing things later
Math3D.VectorSubtract(GameBase.vec3_origin, amove, org);
Math3D.AngleVectors(org, forward, right, up);
-
+
// save the pusher's original position
- GameBase.pushed[GameBase.pushed_p].ent = pusher;
+ GameBase.pushed[GameBase.pushed_p].ent= pusher;
Math3D.VectorCopy(pusher.s.origin, GameBase.pushed[GameBase.pushed_p].origin);
Math3D.VectorCopy(pusher.s.angles, GameBase.pushed[GameBase.pushed_p].angles);
-
+
if (pusher.client != null)
- GameBase.pushed[GameBase.pushed_p].deltayaw = pusher.client.ps.pmove.delta_angles[Defines.YAW];
-
+ GameBase.pushed[GameBase.pushed_p].deltayaw= pusher.client.ps.pmove.delta_angles[Defines.YAW];
+
GameBase.pushed_p++;
-
+
// move the pusher to it's final position
Math3D.VectorAdd(pusher.s.origin, move, pusher.s.origin);
Math3D.VectorAdd(pusher.s.angles, amove, pusher.s.angles);
GameBase.gi.linkentity(pusher);
-
+
// see if any solid entities are inside the final position
-
+
//check= g_edicts + 1;
- for (e = 1; e < GameBase.globals.num_edicts; e++) {
- check = GameBase.g_edicts[e];
+ for (e= 1; e < GameBase.num_edicts; e++)
+ {
+ check= GameBase.g_edicts[e];
if (!check.inuse)
continue;
if (check.movetype == Defines.MOVETYPE_PUSH
@@ -359,12 +388,13 @@ public final class SV {
|| check.movetype == Defines.MOVETYPE_NONE
|| check.movetype == Defines.MOVETYPE_NOCLIP)
continue;
-
+
if (check.area.prev == null)
continue; // not linked in anywhere
-
+
// if the entity is standing on the pusher, it will definitely be moved
- if (check.groundentity != pusher) {
+ if (check.groundentity != pusher)
+ {
// see if the ent needs to be tested
if (check.absmin[0] >= maxs[0]
|| check.absmin[1] >= maxs[1]
@@ -373,79 +403,85 @@ public final class SV {
|| check.absmax[1] <= mins[1]
|| check.absmax[2] <= mins[2])
continue;
-
+
// see if the ent's bbox is inside the pusher's final position
if (SV_TestEntityPosition(check) == null)
continue;
}
-
- if ((pusher.movetype == Defines.MOVETYPE_PUSH) || (check.groundentity == pusher)) {
+
+ if ((pusher.movetype == Defines.MOVETYPE_PUSH) || (check.groundentity == pusher))
+ {
// move this entity
- GameBase.pushed[GameBase.pushed_p].ent = check;
+ GameBase.pushed[GameBase.pushed_p].ent= check;
Math3D.VectorCopy(check.s.origin, GameBase.pushed[GameBase.pushed_p].origin);
Math3D.VectorCopy(check.s.angles, GameBase.pushed[GameBase.pushed_p].angles);
GameBase.pushed_p++;
-
+
// try moving the contacted entity
Math3D.VectorAdd(check.s.origin, move, check.s.origin);
- if (check.client != null) { // FIXME: doesn't rotate monsters?
+ if (check.client != null)
+ { // FIXME: doesn't rotate monsters?
check.client.ps.pmove.delta_angles[Defines.YAW] += amove[Defines.YAW];
}
-
+
// figure movement due to the pusher's amove
Math3D.VectorSubtract(check.s.origin, pusher.s.origin, org);
- org2[0] = Math3D.DotProduct(org, forward);
- org2[1] = -Math3D.DotProduct(org, right);
- org2[2] = Math3D.DotProduct(org, up);
+ org2[0]= Math3D.DotProduct(org, forward);
+ org2[1]= -Math3D.DotProduct(org, right);
+ org2[2]= Math3D.DotProduct(org, up);
Math3D.VectorSubtract(org2, org, move2);
Math3D.VectorAdd(check.s.origin, move2, check.s.origin);
-
+
// may have pushed them off an edge
if (check.groundentity != pusher)
- check.groundentity = null;
-
- block = SV_TestEntityPosition(check);
- if (block == null) { // pushed ok
+ check.groundentity= null;
+
+ block= SV_TestEntityPosition(check);
+ if (block == null)
+ { // pushed ok
GameBase.gi.linkentity(check);
// impact?
continue;
}
-
+
// if it is ok to leave in the old position, do it
// this is only relevent for riding entities, not pushed
// FIXME: this doesn't acount for rotation
Math3D.VectorSubtract(check.s.origin, move, check.s.origin);
- block = SV_TestEntityPosition(check);
-
- if (block == null) {
+ block= SV_TestEntityPosition(check);
+
+ if (block == null)
+ {
GameBase.pushed_p--;
continue;
}
}
-
+
// save off the obstacle so we can call the block function
- GameBase.obstacle = check;
-
+ GameBase.obstacle= check;
+
// move back any entities we already moved
// go backwards, so if the same entity was pushed
// twice, it goes back to the original position
- for (int ip = GameBase.pushed_p - 1; ip >= 0; ip--) {
- p = GameBase.pushed[ip];
+ for (int ip= GameBase.pushed_p - 1; ip >= 0; ip--)
+ {
+ p= GameBase.pushed[ip];
Math3D.VectorCopy(p.origin, p.ent.s.origin);
Math3D.VectorCopy(p.angles, p.ent.s.angles);
- if (p.ent.client != null) {
- p.ent.client.ps.pmove.delta_angles[Defines.YAW] = (short) p.deltayaw;
+ if (p.ent.client != null)
+ {
+ p.ent.client.ps.pmove.delta_angles[Defines.YAW]= (short) p.deltayaw;
}
GameBase.gi.linkentity(p.ent);
}
return false;
}
-
+
// FIXME: is there a better way to handle this?
// see if anything we moved has touched a trigger
- for (int ip = GameBase.pushed_p - 1; ip >= 0; ip--)
+ for (int ip= GameBase.pushed_p - 1; ip >= 0; ip--)
GameBase.G_TouchTriggers(GameBase.pushed[ip].ent);
-
+
return true;
}
@@ -457,57 +493,65 @@ public final class SV {
push all box objects
================
*/
- public static void SV_Physics_Pusher(edict_t ent) {
- float[] move = { 0, 0, 0 };
- float[] amove = { 0, 0, 0 };
+ public static void SV_Physics_Pusher(edict_t ent)
+ {
+ float[] move= { 0, 0, 0 };
+ float[] amove= { 0, 0, 0 };
edict_t part, mv;
-
+
// if not a team captain, so movement will be handled elsewhere
if ((ent.flags & Defines.FL_TEAMSLAVE) != 0)
return;
-
+
// make sure all team slaves can move before commiting
// any moves or calling any think functions
// if the move is blocked, all moved objects will be backed out
// retry:
- GameBase.pushed_p = 0;
- for (part = ent; part != null; part = part.teamchain) {
+ GameBase.pushed_p= 0;
+ for (part= ent; part != null; part= part.teamchain)
+ {
if (part.velocity[0] != 0
|| part.velocity[1] != 0
|| part.velocity[2] != 0
|| part.avelocity[0] != 0
|| part.avelocity[1] != 0
- || part.avelocity[2] != 0) { // object is moving
+ || part.avelocity[2] != 0)
+ { // object is moving
Math3D.VectorScale(part.velocity, Defines.FRAMETIME, move);
Math3D.VectorScale(part.avelocity, Defines.FRAMETIME, amove);
-
+
if (!SV_Push(part, move, amove))
break; // move was blocked
}
}
if (GameBase.pushed_p > Defines.MAX_EDICTS)
- GameBase.gi.error(Defines.ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted");
+
+ SV_GAME.PF_error(Defines.ERR_FATAL, "pushed_p > &pushed[MAX_EDICTS], memory corrupted");
if (part != null) {
// the move failed, bump all nextthink times and back out moves
- for (mv = ent; mv != null; mv = mv.teamchain) {
+ for (mv= ent; mv != null; mv= mv.teamchain)
+ {
if (mv.nextthink > 0)
mv.nextthink += Defines.FRAMETIME;
}
-
+
// if the pusher has a "blocked" function, call it
// otherwise, just stay in place until the obstacle is gone
if (part.blocked != null)
part.blocked.blocked(part, GameBase.obstacle);
- } else { // the move succeeded, so call all think functions
- for (part = ent; part != null; part = part.teamchain) {
+ }
+ else
+ { // the move succeeded, so call all think functions
+ for (part= ent; part != null; part= part.teamchain)
+ {
SV_RunThink(part);
}
}
}
// ==================================================================
-
+
/*
=============
SV_Physics_None
@@ -515,7 +559,8 @@ public final class SV {
Non moving objects can only think
=============
*/
- public static void SV_Physics_None(edict_t ent) {
+ public static void SV_Physics_None(edict_t ent)
+ {
// regular thinking
SV_RunThink(ent);
}
@@ -527,14 +572,15 @@ public final class SV {
A moving object that doesn't obey physics
=============
*/
- public static void SV_Physics_Noclip(edict_t ent) {
+ public static void SV_Physics_Noclip(edict_t ent)
+ {
// regular thinking
if (!SV_RunThink(ent))
return;
-
+
Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles);
Math3D.VectorMA(ent.s.origin, Defines.FRAMETIME, ent.velocity, ent.s.origin);
-
+
GameBase.gi.linkentity(ent);
}
@@ -545,7 +591,7 @@ public final class SV {
==============================================================================
*/
-
+
/*
=============
SV_Physics_Toss
@@ -553,90 +599,96 @@ public final class SV {
Toss, bounce, and fly movement. When onground, do nothing.
=============
*/
- public static void SV_Physics_Toss(edict_t ent) {
+ public static void SV_Physics_Toss(edict_t ent)
+ {
+
trace_t trace;
- float[] move = { 0, 0, 0 };
+ float[] move= { 0, 0, 0 };
float backoff;
edict_t slave;
boolean wasinwater;
boolean isinwater;
- float[] old_origin = { 0, 0, 0 };
-
+ float[] old_origin= { 0, 0, 0 };
+
// regular thinking
SV_RunThink(ent);
-
+
// if not a team captain, so movement will be handled elsewhere
if ((ent.flags & Defines.FL_TEAMSLAVE) != 0)
return;
-
+
if (ent.velocity[2] > 0)
- ent.groundentity = null;
-
- // check for the groundentity going away
+ ent.groundentity= null;
+
+ // check for the groundentity going away
if (ent.groundentity != null)
if (!ent.groundentity.inuse)
- ent.groundentity = null;
-
+ ent.groundentity= null;
+
// if onground, return without moving
if (ent.groundentity != null)
return;
-
+
Math3D.VectorCopy(ent.s.origin, old_origin);
-
+
SV_CheckVelocity(ent);
-
+
// add gravity
if (ent.movetype != Defines.MOVETYPE_FLY && ent.movetype != Defines.MOVETYPE_FLYMISSILE)
SV_AddGravity(ent);
-
+
// move angles
Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles);
-
+
// move origin
Math3D.VectorScale(ent.velocity, Defines.FRAMETIME, move);
- trace = SV_PushEntity(ent, move);
+ trace= SV_PushEntity(ent, move);
if (!ent.inuse)
return;
-
- if (trace.fraction < 1) {
+
+ if (trace.fraction < 1)
+ {
if (ent.movetype == Defines.MOVETYPE_BOUNCE)
- backoff = 1.5f;
+ backoff= 1.5f;
else
- backoff = 1;
-
+ backoff= 1;
+
GameBase.ClipVelocity(ent.velocity, trace.plane.normal, ent.velocity, backoff);
-
+
// stop if on ground
- if (trace.plane.normal[2] > 0.7) {
- if (ent.velocity[2] < 60 || ent.movetype != Defines.MOVETYPE_BOUNCE) {
- ent.groundentity = trace.ent;
- ent.groundentity_linkcount = trace.ent.linkcount;
+ if (trace.plane.normal[2] > 0.7)
+ {
+ if (ent.velocity[2] < 60 || ent.movetype != Defines.MOVETYPE_BOUNCE)
+ {
+ ent.groundentity= trace.ent;
+ ent.groundentity_linkcount= trace.ent.linkcount;
Math3D.VectorCopy(GameBase.vec3_origin, ent.velocity);
Math3D.VectorCopy(GameBase.vec3_origin, ent.avelocity);
}
}
-
+
// if (ent.touch)
// ent.touch (ent, trace.ent, &trace.plane, trace.surface);
}
-
+
// check for water transition
- wasinwater = (ent.watertype & Defines.MASK_WATER) != 0;
- ent.watertype = GameBase.gi.pointcontents.pointcontents(ent.s.origin);
- isinwater = (ent.watertype & Defines.MASK_WATER) != 0;
-
+ wasinwater= (ent.watertype & Defines.MASK_WATER) != 0;
+ ent.watertype= GameBase.gi.pointcontents.pointcontents(ent.s.origin);
+ isinwater= (ent.watertype & Defines.MASK_WATER) != 0;
+
if (isinwater)
- ent.waterlevel = 1;
+ ent.waterlevel= 1;
else
- ent.waterlevel = 0;
-
+ ent.waterlevel= 0;
+
if (!wasinwater && isinwater)
GameBase.gi.positioned_sound(old_origin, ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0);
else if (wasinwater && !isinwater)
GameBase.gi.positioned_sound(ent.s.origin, ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/h2ohit1.wav"), 1, 1, 0);
-
+
// move teamslaves
- for (slave = ent.teamchain; slave != null; slave = slave.teamchain) {
+ for (slave= ent.teamchain; slave != null; slave= slave.teamchain)
+ {
Math3D.VectorCopy(ent.s.origin, slave.s.origin);
GameBase.gi.linkentity(slave);
}
@@ -649,7 +701,7 @@ public final class SV {
===============================================================================
*/
-
+
/*
=============
SV_Physics_Step
@@ -662,129 +714,141 @@ public final class SV {
FIXME: is this true?
=============
*/
-
+
// FIXME: hacked in for E3 demo
-
- public static void SV_AddRotationalFriction(edict_t ent) {
+
+ public static void SV_AddRotationalFriction(edict_t ent)
+ {
int n;
float adjustment;
-
+
Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity, ent.s.angles);
- adjustment = Defines.FRAMETIME * Defines.sv_stopspeed * Defines.sv_friction;
- for (n = 0; n < 3; n++) {
- if (ent.avelocity[n] > 0) {
+ adjustment= Defines.FRAMETIME * Defines.sv_stopspeed * Defines.sv_friction;
+ for (n= 0; n < 3; n++)
+ {
+ if (ent.avelocity[n] > 0)
+ {
ent.avelocity[n] -= adjustment;
if (ent.avelocity[n] < 0)
- ent.avelocity[n] = 0;
- } else {
+ ent.avelocity[n]= 0;
+ }
+ else
+ {
ent.avelocity[n] += adjustment;
if (ent.avelocity[n] > 0)
- ent.avelocity[n] = 0;
+ ent.avelocity[n]= 0;
}
}
}
- public static void SV_Physics_Step(edict_t ent) {
+ public static void SV_Physics_Step(edict_t ent)
+ {
boolean wasonground;
- boolean hitsound = false;
+ boolean hitsound= false;
float vel[];
float speed, newspeed, control;
float friction;
edict_t groundentity;
int mask;
-
+
// airborn monsters should always check for ground
if (ent.groundentity == null)
M.M_CheckGround(ent);
-
- groundentity = ent.groundentity;
-
+
+ groundentity= ent.groundentity;
+
SV_CheckVelocity(ent);
-
+
if (groundentity != null)
- wasonground = true;
+ wasonground= true;
else
- wasonground = false;
-
+ wasonground= false;
+
if (ent.avelocity[0] != 0 || ent.avelocity[1] != 0 || ent.avelocity[2] != 0)
SV_AddRotationalFriction(ent);
-
+
// add gravity except:
// flying monsters
// swimming monsters who are in the water
if (!wasonground)
if (0 == (ent.flags & Defines.FL_FLY))
- if (!((ent.flags & Defines.FL_SWIM) != 0 && (ent.waterlevel > 2))) {
+ if (!((ent.flags & Defines.FL_SWIM) != 0 && (ent.waterlevel > 2)))
+ {
if (ent.velocity[2] < GameBase.sv_gravity.value * -0.1)
- hitsound = true;
+ hitsound= true;
if (ent.waterlevel == 0)
SV_AddGravity(ent);
}
-
+
// friction for flying monsters that have been given vertical velocity
- if ((ent.flags & Defines.FL_FLY) != 0 && (ent.velocity[2] != 0)) {
- speed = Math.abs(ent.velocity[2]);
- control = speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed;
- friction = Defines.sv_friction / 3;
- newspeed = speed - (Defines.FRAMETIME * control * friction);
+ if ((ent.flags & Defines.FL_FLY) != 0 && (ent.velocity[2] != 0))
+ {
+ speed= Math.abs(ent.velocity[2]);
+ control= speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed;
+ friction= Defines.sv_friction / 3;
+ newspeed= speed - (Defines.FRAMETIME * control * friction);
if (newspeed < 0)
- newspeed = 0;
+ newspeed= 0;
newspeed /= speed;
ent.velocity[2] *= newspeed;
}
-
+
// friction for flying monsters that have been given vertical velocity
- if ((ent.flags & Defines.FL_SWIM) != 0 && (ent.velocity[2] != 0)) {
- speed = Math.abs(ent.velocity[2]);
- control = speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed;
- newspeed = speed - (Defines.FRAMETIME * control * Defines.sv_waterfriction * ent.waterlevel);
+ if ((ent.flags & Defines.FL_SWIM) != 0 && (ent.velocity[2] != 0))
+ {
+ speed= Math.abs(ent.velocity[2]);
+ control= speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed;
+ newspeed= speed - (Defines.FRAMETIME * control * Defines.sv_waterfriction * ent.waterlevel);
if (newspeed < 0)
- newspeed = 0;
+ newspeed= 0;
newspeed /= speed;
ent.velocity[2] *= newspeed;
}
-
- if (ent.velocity[2] != 0 || ent.velocity[1] != 0 || ent.velocity[0] != 0) {
+
+ if (ent.velocity[2] != 0 || ent.velocity[1] != 0 || ent.velocity[0] != 0)
+ {
// apply friction
// let dead monsters who aren't completely onground slide
if ((wasonground) || 0 != (ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)))
- if (!(ent.health <= 0.0 && !M.M_CheckBottom(ent))) {
- vel = ent.velocity;
- speed = (float) Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1]);
- if (speed != 0) {
- friction = Defines.sv_friction;
-
- control = speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed;
- newspeed = speed - Defines.FRAMETIME * control * friction;
-
+ if (!(ent.health <= 0.0 && !M.M_CheckBottom(ent)))
+ {
+ vel= ent.velocity;
+ speed= (float) Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1]);
+ if (speed != 0)
+ {
+ friction= Defines.sv_friction;
+
+ control= speed < Defines.sv_stopspeed ? Defines.sv_stopspeed : speed;
+ newspeed= speed - Defines.FRAMETIME * control * friction;
+
if (newspeed < 0)
- newspeed = 0;
+ newspeed= 0;
newspeed /= speed;
-
+
vel[0] *= newspeed;
vel[1] *= newspeed;
}
}
-
+
if ((ent.svflags & Defines.SVF_MONSTER) != 0)
- mask = Defines.MASK_MONSTERSOLID;
+ mask= Defines.MASK_MONSTERSOLID;
else
- mask = Defines.MASK_SOLID;
-
+ mask= Defines.MASK_SOLID;
+
SV_FlyMove(ent, Defines.FRAMETIME, mask);
-
+
GameBase.gi.linkentity(ent);
GameBase.G_TouchTriggers(ent);
if (!ent.inuse)
return;
-
+
if (ent.groundentity != null)
if (!wasonground)
if (hitsound)
GameBase.gi.sound(ent, 0, GameBase.gi.soundindex("world/land.wav"), 1, 1, 0);
}
-
- // regular thinking
+
+ // regular thinking
SV_RunThink(ent);
}
@@ -800,38 +864,45 @@ public final class SV {
*/
// FIXME since we need to test end position contents here, can we avoid doing
// it again later in catagorize position?
- public static boolean SV_movestep(edict_t ent, float[] move, boolean relink) {
+ public static boolean SV_movestep(edict_t ent, float[] move, boolean relink)
+ {
float dz;
- float[] oldorg = { 0, 0, 0 };
- float[] neworg = { 0, 0, 0 };
- float[] end = { 0, 0, 0 };
-
- trace_t trace = null;// = new trace_t();
+ float[] oldorg= { 0, 0, 0 };
+ float[] neworg= { 0, 0, 0 };
+ float[] end= { 0, 0, 0 };
+
+ trace_t trace= null; // = new trace_t();
int i;
float stepsize;
- float[] test = { 0, 0, 0 };
+ float[] test= { 0, 0, 0 };
int contents;
-
+
// try the move
Math3D.VectorCopy(ent.s.origin, oldorg);
Math3D.VectorAdd(ent.s.origin, move, neworg);
-
+
// flying monsters don't step up
- if ((ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)) != 0) {
+ if ((ent.flags & (Defines.FL_SWIM | Defines.FL_FLY)) != 0)
+ {
// try one move with vertical motion, then one without
- for (i = 0; i < 2; i++) {
+ for (i= 0; i < 2; i++)
+ {
Math3D.VectorAdd(ent.s.origin, move, neworg);
- if (i == 0 && ent.enemy != null) {
+ if (i == 0 && ent.enemy != null)
+ {
if (ent.goalentity == null)
- ent.goalentity = ent.enemy;
- dz = ent.s.origin[2] - ent.goalentity.s.origin[2];
- if (ent.goalentity.client != null) {
+ ent.goalentity= ent.enemy;
+ dz= ent.s.origin[2] - ent.goalentity.s.origin[2];
+ if (ent.goalentity.client != null)
+ {
if (dz > 40)
neworg[2] -= 8;
if (!((ent.flags & Defines.FL_SWIM) != 0 && (ent.waterlevel < 2)))
if (dz < 30)
neworg[2] += 8;
- } else {
+ }
+ else
+ {
if (dz > 8)
neworg[2] -= 8;
else if (dz > 0)
@@ -842,104 +913,118 @@ public final class SV {
neworg[2] += dz;
}
}
- trace = GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, neworg, ent, Defines.MASK_MONSTERSOLID);
-
+ trace= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, neworg, ent, Defines.MASK_MONSTERSOLID);
+
// fly monsters don't enter water voluntarily
- if ((ent.flags & Defines.FL_FLY) != 0) {
- if (ent.waterlevel == 0) {
- test[0] = trace.endpos[0];
- test[1] = trace.endpos[1];
- test[2] = trace.endpos[2] + ent.mins[2] + 1;
- contents = GameBase.gi.pointcontents.pointcontents(test);
+ if ((ent.flags & Defines.FL_FLY) != 0)
+ {
+ if (ent.waterlevel == 0)
+ {
+ test[0]= trace.endpos[0];
+ test[1]= trace.endpos[1];
+ test[2]= trace.endpos[2] + ent.mins[2] + 1;
+ contents= GameBase.gi.pointcontents.pointcontents(test);
if ((contents & Defines.MASK_WATER) != 0)
return false;
}
}
-
+
// swim monsters don't exit water voluntarily
- if ((ent.flags & Defines.FL_SWIM) != 0) {
- if (ent.waterlevel < 2) {
- test[0] = trace.endpos[0];
- test[1] = trace.endpos[1];
- test[2] = trace.endpos[2] + ent.mins[2] + 1;
- contents = GameBase.gi.pointcontents.pointcontents(test);
+ if ((ent.flags & Defines.FL_SWIM) != 0)
+ {
+ if (ent.waterlevel < 2)
+ {
+ test[0]= trace.endpos[0];
+ test[1]= trace.endpos[1];
+ test[2]= trace.endpos[2] + ent.mins[2] + 1;
+ contents= GameBase.gi.pointcontents.pointcontents(test);
if ((contents & Defines.MASK_WATER) == 0)
return false;
}
}
-
- if (trace.fraction == 1) {
+
+ if (trace.fraction == 1)
+ {
Math3D.VectorCopy(trace.endpos, ent.s.origin);
- if (relink) {
+ if (relink)
+ {
GameBase.gi.linkentity(ent);
GameBase.G_TouchTriggers(ent);
}
return true;
}
-
+
if (ent.enemy == null)
break;
}
-
+
return false;
}
-
+
// push down from a step height above the wished position
if ((ent.monsterinfo.aiflags & Defines.AI_NOSTEP) == 0)
- stepsize = GameBase.STEPSIZE;
+ stepsize= GameBase.STEPSIZE;
else
- stepsize = 1;
-
+ stepsize= 1;
+
neworg[2] += stepsize;
Math3D.VectorCopy(neworg, end);
end[2] -= stepsize * 2;
-
- trace = GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID);
-
+
+ trace= GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID);
+
if (trace.allsolid)
return false;
-
- if (trace.startsolid) {
+
+ if (trace.startsolid)
+ {
neworg[2] -= stepsize;
- trace = GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID);
+ trace= GameBase.gi.trace(neworg, ent.mins, ent.maxs, end, ent, Defines.MASK_MONSTERSOLID);
if (trace.allsolid || trace.startsolid)
return false;
}
-
+
// don't go in to water
- if (ent.waterlevel == 0) {
- test[0] = trace.endpos[0];
- test[1] = trace.endpos[1];
- test[2] = trace.endpos[2] + ent.mins[2] + 1;
- contents = GameBase.gi.pointcontents.pointcontents(test);
-
+ if (ent.waterlevel == 0)
+ {
+ test[0]= trace.endpos[0];
+ test[1]= trace.endpos[1];
+ test[2]= trace.endpos[2] + ent.mins[2] + 1;
+ contents= GameBase.gi.pointcontents.pointcontents(test);
+
if ((contents & Defines.MASK_WATER) != 0)
return false;
}
-
- if (trace.fraction == 1) {
+
+ if (trace.fraction == 1)
+ {
// if monster had the ground pulled out, go ahead and fall
- if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) {
+ if ((ent.flags & Defines.FL_PARTIALGROUND) != 0)
+ {
Math3D.VectorAdd(ent.s.origin, move, ent.s.origin);
- if (relink) {
+ if (relink)
+ {
GameBase.gi.linkentity(ent);
GameBase.G_TouchTriggers(ent);
}
- ent.groundentity = null;
+ ent.groundentity= null;
return true;
}
-
+
return false; // walked off an edge
}
-
+
// check point traces down for dangling corners
Math3D.VectorCopy(trace.endpos, ent.s.origin);
-
- if (!M.M_CheckBottom(ent)) {
- if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) {
+
+ if (!M.M_CheckBottom(ent))
+ {
+ if ((ent.flags & Defines.FL_PARTIALGROUND) != 0)
+ {
// entity had floor mostly pulled out from underneath it
// and is trying to correct
- if (relink) {
+ if (relink)
+ {
GameBase.gi.linkentity(ent);
GameBase.G_TouchTriggers(ent);
}
@@ -948,15 +1033,17 @@ public final class SV {
Math3D.VectorCopy(oldorg, ent.s.origin);
return false;
}
-
- if ((ent.flags & Defines.FL_PARTIALGROUND) != 0) {
+
+ if ((ent.flags & Defines.FL_PARTIALGROUND) != 0)
+ {
ent.flags &= ~Defines.FL_PARTIALGROUND;
}
- ent.groundentity = trace.ent;
- ent.groundentity_linkcount = trace.ent.linkcount;
-
+ ent.groundentity= trace.ent;
+ ent.groundentity_linkcount= trace.ent.linkcount;
+
// the move is ok
- if (relink) {
+ if (relink)
+ {
GameBase.gi.linkentity(ent);
GameBase.G_TouchTriggers(ent);
}
@@ -972,23 +1059,26 @@ public final class SV {
======================
*/
- public static boolean SV_StepDirection(edict_t ent, float yaw, float dist) {
- float[] move = { 0, 0, 0 };
- float[] oldorigin = { 0, 0, 0 };
+ public static boolean SV_StepDirection(edict_t ent, float yaw, float dist)
+ {
+ float[] move= { 0, 0, 0 };
+ float[] oldorigin= { 0, 0, 0 };
float delta;
-
- ent.ideal_yaw = yaw;
+
+ ent.ideal_yaw= yaw;
M.M_ChangeYaw(ent);
-
- yaw = (float) (yaw * Math.PI * 2 / 360);
- move[0] = (float) Math.cos(yaw) * dist;
- move[1] = (float) Math.sin(yaw) * dist;
- move[2] = 0;
-
+
+ yaw= (float) (yaw * Math.PI * 2 / 360);
+ move[0]= (float) Math.cos(yaw) * dist;
+ move[1]= (float) Math.sin(yaw) * dist;
+ move[2]= 0;
+
Math3D.VectorCopy(ent.s.origin, oldorigin);
- if (SV_movestep(ent, move, false)) {
- delta = ent.s.angles[Defines.YAW] - ent.ideal_yaw;
- if (delta > 45 && delta < 315) { // not turned far enough, so don't take the step
+ if (SV_movestep(ent, move, false))
+ {
+ delta= ent.s.angles[Defines.YAW] - ent.ideal_yaw;
+ if (delta > 45 && delta < 315)
+ { // not turned far enough, so don't take the step
Math3D.VectorCopy(oldorigin, ent.s.origin);
}
GameBase.gi.linkentity(ent);
@@ -1006,86 +1096,93 @@ public final class SV {
======================
*/
- public static void SV_FixCheckBottom(edict_t ent) {
+ public static void SV_FixCheckBottom(edict_t ent)
+ {
ent.flags |= Defines.FL_PARTIALGROUND;
}
- public static void SV_NewChaseDir(edict_t actor, edict_t enemy, float dist) {
+ public static void SV_NewChaseDir(edict_t actor, edict_t enemy, float dist)
+ {
float deltax, deltay;
- float d[] = { 0, 0, 0 };
+ float d[]= { 0, 0, 0 };
float tdir, olddir, turnaround;
-
+
//FIXME: how did we get here with no enemy
if (enemy == null)
{
- Com.d("SV_NewChaseDir without enemy!");
+ Com.DPrintf("SV_NewChaseDir without enemy!\n");
return;
}
- olddir = Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45);
- turnaround = Math3D.anglemod(olddir - 180);
-
- deltax = enemy.s.origin[0] - actor.s.origin[0];
- deltay = enemy.s.origin[1] - actor.s.origin[1];
+ olddir= Math3D.anglemod((int) (actor.ideal_yaw / 45) * 45);
+ turnaround= Math3D.anglemod(olddir - 180);
+
+ deltax= enemy.s.origin[0] - actor.s.origin[0];
+ deltay= enemy.s.origin[1] - actor.s.origin[1];
if (deltax > 10)
- d[1] = 0;
+ d[1]= 0;
else if (deltax < -10)
- d[1] = 180;
+ d[1]= 180;
else
- d[1] = GameBase.DI_NODIR;
+ d[1]= GameBase.DI_NODIR;
if (deltay < -10)
- d[2] = 270;
+ d[2]= 270;
else if (deltay > 10)
- d[2] = 90;
+ d[2]= 90;
else
- d[2] = GameBase.DI_NODIR;
-
+ d[2]= GameBase.DI_NODIR;
+
// try direct route
- if (d[1] != GameBase.DI_NODIR && d[2] != GameBase.DI_NODIR) {
+ if (d[1] != GameBase.DI_NODIR && d[2] != GameBase.DI_NODIR)
+ {
if (d[1] == 0)
- tdir = d[2] == 90 ? 45 : 315;
+ tdir= d[2] == 90 ? 45 : 315;
else
- tdir = d[2] == 90 ? 135 : 215;
-
+ tdir= d[2] == 90 ? 135 : 215;
+
if (tdir != turnaround && SV_StepDirection(actor, tdir, dist))
return;
}
-
+
// try other directions
- if (((Lib.rand() & 3) & 1) != 0 || Math.abs(deltay) > Math.abs(deltax)) {
- tdir = d[1];
- d[1] = d[2];
- d[2] = tdir;
+ if (((Lib.rand() & 3) & 1) != 0 || Math.abs(deltay) > Math.abs(deltax))
+ {
+ tdir= d[1];
+ d[1]= d[2];
+ d[2]= tdir;
}
-
+
if (d[1] != GameBase.DI_NODIR && d[1] != turnaround && SV_StepDirection(actor, d[1], dist))
return;
-
+
if (d[2] != GameBase.DI_NODIR && d[2] != turnaround && SV_StepDirection(actor, d[2], dist))
return;
-
+
/* there is no direct path to the player, so pick another direction */
-
+
if (olddir != GameBase.DI_NODIR && SV_StepDirection(actor, olddir, dist))
return;
-
- if ((Lib.rand() & 1) != 0) /*randomly determine direction of search*/ {
- for (tdir = 0; tdir <= 315; tdir += 45)
+
+ if ((Lib.rand() & 1) != 0) /*randomly determine direction of search*/
+ {
+ for (tdir= 0; tdir <= 315; tdir += 45)
if (tdir != turnaround && SV_StepDirection(actor, tdir, dist))
return;
- } else {
- for (tdir = 315; tdir >= 0; tdir -= 45)
+ }
+ else
+ {
+ for (tdir= 315; tdir >= 0; tdir -= 45)
if (tdir != turnaround && SV_StepDirection(actor, tdir, dist))
return;
}
-
+
if (turnaround != GameBase.DI_NODIR && SV_StepDirection(actor, turnaround, dist))
return;
-
- actor.ideal_yaw = olddir; // can't move
-
+
+ actor.ideal_yaw= olddir; // can't move
+
// if a bridge was pulled out from underneath a monster, it may not have
// a valid standing position at all
-
+
if (!M.M_CheckBottom(actor))
SV_FixCheckBottom(actor);
}
@@ -1095,11 +1192,13 @@ public final class SV {
SV_CloseEnough
======================
- *///ok
- public static boolean SV_CloseEnough(edict_t ent, edict_t goal, float dist) {
+ */ //ok
+ public static boolean SV_CloseEnough(edict_t ent, edict_t goal, float dist)
+ {
int i;
-
- for (i = 0; i < 3; i++) {
+
+ for (i= 0; i < 3; i++)
+ {
if (goal.absmin[i] > ent.absmax[i] + dist)
return false;
if (goal.absmax[i] < ent.absmin[i] - dist)
diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java
index f9cbe2c..07a97e8 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.2.2.1 2004-07-09 08:38:25 hzi Exp $
+// $Id: SV_CCMDS.java,v 1.2.2.2 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
@@ -28,11 +28,11 @@ import jake2.game.*;
import jake2.qcommon.*;
import jake2.sys.NET;
import jake2.sys.Sys;
-import jake2.util.Lib;
+import jake2.util.QuakeFile;
import jake2.util.Vargs;
import java.io.*;
-import java.util.Date;
+import java.util.Calendar;
public class SV_CCMDS extends SV_ENTS {
@@ -64,12 +64,12 @@ public class SV_CCMDS extends SV_ENTS {
// make sure the server is listed public
Cvar.Set("public", "1");
- for (i = 1; i < MAX_MASTERS; i++)
+ for (i= 1; i < MAX_MASTERS; i++)
//memset (&master_adr[i], 0, sizeof(master_adr[i]));
- master_adr[i] = new netadr_t();
+ master_adr[i]= new netadr_t();
- slot = 1; // slot 0 will always contain the id master
- for (i = 1; i < Cmd.Argc(); i++) {
+ slot= 1; // slot 0 will always contain the id master
+ for (i= 1; i < Cmd.Argc(); i++) {
if (slot == MAX_MASTERS)
break;
@@ -78,7 +78,7 @@ public class SV_CCMDS extends SV_ENTS {
continue;
}
if (master_adr[slot].port == 0)
- master_adr[slot].port = //BigShort (PORT_MASTER);
+ master_adr[slot].port= //BigShort (PORT_MASTER);
PORT_MASTER;
Com.Printf("Master server at " + NET.AdrToString(master_adr[slot]) + "\n");
@@ -90,7 +90,7 @@ public class SV_CCMDS extends SV_ENTS {
slot++;
}
- svs.last_heartbeat = -9999999;
+ svs.last_heartbeat= -9999999;
}
/*
@@ -109,18 +109,18 @@ public class SV_CCMDS extends SV_ENTS {
if (Cmd.Argc() < 2)
return false;
- s = Cmd.Argv(1);
+ s= Cmd.Argv(1);
// numeric values are just slot numbers
if (s.charAt(0) >= '0' && s.charAt(0) <= '9') {
- idnum = atoi(Cmd.Argv(1));
+ idnum= atoi(Cmd.Argv(1));
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;
+ sv_client= svs.clients[idnum];
+ sv_player= sv_client.edict;
if (0 == sv_client.state) {
Com.Printf("Client " + idnum + " is not active\n");
return false;
@@ -129,13 +129,13 @@ public class SV_CCMDS extends SV_ENTS {
}
// check for a name match
- for (i = 0; i < maxclients.value; i++) {
- cl = svs.clients[i];
+ for (i= 0; i < maxclients.value; i++) {
+ cl= svs.clients[i];
if (0 == cl.state)
continue;
if (0 == strcmp(cl.name, s)) {
- sv_client = cl;
- sv_player = sv_client.edict;
+ sv_client= cl;
+ sv_player= sv_client.edict;
return true;
}
}
@@ -175,28 +175,28 @@ public class SV_CCMDS extends SV_ENTS {
Com.DPrintf("SV_WipeSaveGame(" + savename + ")\n");
- name = FS.Gamedir() + "/save/" + savename + "/server.ssv";
+ name= FS.Gamedir() + "/save/" + savename + "/server.ssv";
remove(name);
- name = FS.Gamedir() + "/save/" + savename + "/game.ssv";
+ name= FS.Gamedir() + "/save/" + savename + "/game.ssv";
remove(name);
- name = FS.Gamedir() + "/save/" + savename + "/*.sav";
+ name= FS.Gamedir() + "/save/" + savename + "/*.sav";
- File f = Sys.FindFirst(name, 0, 0);
+ File f= Sys.FindFirst(name, 0, 0);
while (f != null) {
f.delete();
- f = Sys.FindNext();
+ f= Sys.FindNext();
}
Sys.FindClose();
- name = FS.Gamedir() + "/save/" + savename + "/*.sv2";
+ name= FS.Gamedir() + "/save/" + savename + "/*.sv2";
- f = Sys.FindFirst(name, 0, 0);
+ f= Sys.FindFirst(name, 0, 0);
while (f != null) {
f.delete();
- f = Sys.FindNext();
+ f= Sys.FindNext();
}
Sys.FindClose();
}
@@ -208,20 +208,19 @@ public class SV_CCMDS extends SV_ENTS {
*/
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");
+ int l= -1;
+ byte buffer[]= new byte[65536];
+ //Com.DPrintf("CopyFile (" + src + ", " + dst + ")\n");
try {
- f1 = new RandomAccessFile(src, "r");
+ f1= new RandomAccessFile(src, "r");
}
catch (Exception e) {
return;
}
try {
- f2 = new RandomAccessFile(dst, "rw");
+ f2= new RandomAccessFile(dst, "rw");
}
catch (Exception e) {
try {
@@ -236,7 +235,7 @@ public class SV_CCMDS extends SV_ENTS {
while (true) {
try {
- l = f1.read(buffer, 0, 65536);
+ l= f1.read(buffer, 0, 65536);
}
catch (IOException e1) {
@@ -286,24 +285,25 @@ public class SV_CCMDS extends SV_ENTS {
SV_WipeSavegame(dst);
// copy the savegame over
- name = FS.Gamedir() + "/save/" + src + "/server.ssv";
- name2 = FS.Gamedir() + "/save/" + dst + "/server.ssv";
+ name= FS.Gamedir() + "/save/" + src + "/server.ssv";
+ name2= FS.Gamedir() + "/save/" + dst + "/server.ssv";
FS.CreatePath(name2);
CopyFile(name, name2);
- name = FS.Gamedir() + "/save/" + src + "/game.ssv";
- name2 = "/save/" + dst + "/game.ssv";
+ name= FS.Gamedir() + "/save/" + src + "/game.ssv";
+ name2= FS.Gamedir() + "/save/" + dst + "/game.ssv";
CopyFile(name, name2);
- String name1 = FS.Gamedir() + "/save/" + src + "/";
- len = name1.length();
- name = FS.Gamedir() + "/save/" + src + "/*.sav";
+ String name1= FS.Gamedir() + "/save/" + src + "/";
+ len= name1.length();
+ name= FS.Gamedir() + "/save/" + src + "/*.sav";
- found = Sys.FindFirst(name, 0, 0);
+ found= Sys.FindFirst(name, 0, 0);
while (found != null) {
- name = name1 + '/' + found.getName();
- name2 = FS.Gamedir() + "/save/" + dst + "/" + found.getName();
+ name= name1 + found.getName();
+ name2= FS.Gamedir() + "/save/" + dst + "/" + found.getName();
+
CopyFile(name, name2);
// change sav to sv2
@@ -311,12 +311,12 @@ public class SV_CCMDS extends SV_ENTS {
//strcpy(name + l - 3, "sv2");
//l = strlen(name2);
//strcpy(name2 + l - 3, "sv2");
- name = name.substring(0, name.length() - 3) + "sv2";
- name2 = name.substring(0, name2.length() - 3) + "sv2";
+ name= name.substring(0, name.length() - 3) + "sv2";
+ name2= name2.substring(0, name2.length() - 3) + "sv2";
CopyFile(name, name2);
- found = Sys.FindNext();
+ found= Sys.FindNext();
}
Sys.FindClose();
}
@@ -328,38 +328,30 @@ public class SV_CCMDS extends SV_ENTS {
==============
*/
public static void SV_WriteLevelFile() {
- //char name[MAX_OSPATH];
- //FILE * f;
String name;
- RandomAccessFile f;
+ QuakeFile f;
Com.DPrintf("SV_WriteLevelFile()\n");
- name = FS.Gamedir() + "/save/current/" + sv.name + ".sv2";
+ name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2";
try {
- f = new RandomAccessFile(name, "rw");
- }
- catch (Exception e) {
- Com.Printf("Failed to open " + name + "\n");
- return;
- }
- try {
- //fwrite(sv.configstrings, sizeof(sv.configstrings), 1, f);
- for (int i = 0; i < sv.configstrings.length; i++)
- Lib.fwriteString(sv.configstrings[i], MAX_QPATH, f);
+ f= new QuakeFile(name, "rw");
+
+ for (int i= 0; i < MAX_CONFIGSTRINGS; i++)
+ f.writeString(sv.configstrings[i]);
CM.CM_WritePortalState(f);
f.close();
}
catch (Exception e) {
- Com.Printf("IOError in SV_WriteLevelFile: " + e);
+ Com.Printf("Failed to open " + name + "\n");
e.printStackTrace();
}
- name = FS.Gamedir() + "/save/current/" + sv.name + ".sav";
- ge.WriteLevel(name);
+ name= FS.Gamedir() + "/save/current/" + sv.name + ".sav";
+ GameSave.WriteLevel(name);
}
/*
@@ -371,33 +363,28 @@ public class SV_CCMDS extends SV_ENTS {
public static void SV_ReadLevelFile() {
//char name[MAX_OSPATH];
String name;
- RandomAccessFile f;
+ QuakeFile f;
Com.DPrintf("SV_ReadLevelFile()\n");
- name = FS.Gamedir() + "/save/current/" + sv.name + ".sv2";
+ name= FS.Gamedir() + "/save/current/" + sv.name + ".sv2";
try {
- f = new RandomAccessFile(name, "r");
- }
- catch (Exception e) {
- Com.Printf("Failed to open " + name + "\n");
- return;
- }
- // FS.Read(sv.configstrings, sizeof(sv.configstrings), f);
- for (int n = 0; n < MAX_CONFIGSTRINGS; n++)
- sv.configstrings[n] = Lib.freadString(f, MAX_QPATH);
+ f= new QuakeFile(name, "r");
- CM.CM_ReadPortalState(f);
+ for (int n= 0; n < MAX_CONFIGSTRINGS; n++)
+ sv.configstrings[n]= f.readString();
+
+ CM.CM_ReadPortalState(f);
- try {
f.close();
}
catch (IOException e1) {
+ Com.Printf("Failed to open " + name + "\n");
e1.printStackTrace();
}
- name = FS.Gamedir() + "/save/current/" + sv.name + ".sav";
- ge.ReadLevel(name);
+ name= FS.Gamedir() + "/save/current/" + sv.name + ".sav";
+ GameSave.ReadLevel(name);
}
/*
@@ -407,78 +394,67 @@ public class SV_CCMDS extends SV_ENTS {
==============
*/
public static void SV_WriteServerFile(boolean autosave) {
- RandomAccessFile f;
+ QuakeFile f;
cvar_t var;
- //char name[MAX_OSPATH], string[128];
- //char comment[32];
- //time_t aclock;
- //struct tm * newtime;
- String name, string, comment;
+
+ String filename, name, string, comment;
Com.DPrintf("SV_WriteServerFile(" + (autosave ? "true" : "false") + ")\n");
- name = FS.Gamedir() + "/save/current/server.ssv";
+ filename= FS.Gamedir() + "/save/current/server.ssv";
try {
- f = new RandomAccessFile(name, "rw");
- } catch (FileNotFoundException e) {
- f = null;
- }
- if (f == null) {
- Com.Printf("Couldn't write " + name + "\n");
- return;
- }
- // write the comment field
- //memset(comment, 0, sizeof(comment));
-
- if (!autosave) {
- //time( aclock);
- //newtime = localtime( aclock);
- Date newtime = new Date();
- comment =
- Com.sprintf(
- "%2i:%2i %2i/%2i ",
- new Vargs().add(newtime.getHours()).add(newtime.getMinutes()).add(newtime.getMonth() + 1).add(newtime.getDay()));
- comment += sv.configstrings[CS_NAME];
- }
- else { // autosaved
- comment = "ENTERING " + sv.configstrings[CS_NAME];
- }
+ f= new QuakeFile(filename, "rw");
+
+ if (!autosave) {
+ Calendar c= Calendar.getInstance();
+ comment=
+ Com.sprintf(
+ "%2i:%2i %2i/%2i ",
+ new Vargs().add(c.get(Calendar.HOUR_OF_DAY)).add(c.get(Calendar.MINUTE)).add(c.get(Calendar.MONTH) + 1).add(
+ c.get(Calendar.DAY_OF_MONTH)));
+ comment += sv.configstrings[CS_NAME];
+ }
+ else {
+ // autosaved
+ comment= "ENTERING " + sv.configstrings[CS_NAME];
+ }
- try {
- fwriteString(comment, 32, f);
- fwriteString(svs.mapcmd, MAX_TOKEN_CHARS, f);
+ f.writeString(comment);
+ f.writeString(svs.mapcmd);
- } catch (IOException e1) {}
+ // write the mapcmd
- // write the mapcmd
-
- // write all CVAR_LATCH cvars
- // these will be things like coop, skill, deathmatch, etc
- 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) {
- Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n");
- continue;
- }
- //memset(name, 0, sizeof(name));
- //memset(string, 0, sizeof(string));
- name = var.name;
- string = var.string;
- try {
- fwriteString(name, MAX_OSPATH, f);
- fwriteString(string, 128, f);
- } catch (IOException e2) {}
-
- }
+ // write all CVAR_LATCH cvars
+ // these will be things like coop, skill, deathmatch, etc
+ 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) {
+ Com.Printf("Cvar too long: " + var.name + " = " + var.string + "\n");
+ continue;
+ }
- try {
+ name= var.name;
+ string= var.string;
+ try {
+ f.writeString(name);
+ f.writeString(string);
+ }
+ catch (IOException e2) {
+ }
+
+ }
+ // rst: for termination.
+ f.writeString(null);
f.close();
- } catch (IOException e2) {}
+ }
+ catch (Exception e) {
+ Com.Printf("Couldn't write " + filename + "\n");
+ }
// write game state
- name = FS.Gamedir() + "/save/current/game.ssv";
- ge.WriteGame(name, autosave);
+ filename= FS.Gamedir() + "/save/current/game.ssv";
+ GameSave.WriteGame(filename, autosave);
}
/*
@@ -488,57 +464,53 @@ public class SV_CCMDS extends SV_ENTS {
==============
*/
public static void SV_ReadServerFile() {
- RandomAccessFile f;
- //char name[MAX_OSPATH], string[128];
- //char comment[32];
- //char mapcmd[MAX_TOKEN_CHARS];
+ String filename, name= "", string, comment, mapcmd;
+ try {
+ QuakeFile f;
- String name, string, comment, mapcmd;
+ mapcmd= "";
- Com.DPrintf("SV_ReadServerFile()\n");
+ Com.DPrintf("SV_ReadServerFile()\n");
- name = FS.Gamedir() + "/save/current/server.ssv";
- try {
- f = new RandomAccessFile(name, "r");
- }
- catch (FileNotFoundException e1) {
- Com.Printf("Couldn't read " + name + "\n");
- e1.printStackTrace();
- return;
- }
- // read the comment field
- comment = Lib.freadString(f, 32);
+ filename= FS.Gamedir() + "/save/current/server.ssv";
- // read the mapcmd
- mapcmd = Lib.freadString(f, MAX_TOKEN_CHARS);
+ f= new QuakeFile(filename, "r");
- // read all CVAR_LATCH cvars
- // these will be things like coop, skill, deathmatch, etc
- while (true) {
- name = Lib.freadString(f, MAX_OSPATH);
- //if (!fread(name, 1, sizeof(name), f))
- if (name == null)
- break;
- string = Lib.freadString(f, 128);
- Com.DPrintf("Set " + name + " = " + string + "\n");
- Cvar.ForceSet(name, string);
- }
+ // read the comment field
+
+ comment= f.readString();
+
+ // read the mapcmd
+
+ mapcmd= f.readString();
+
+ // read all CVAR_LATCH cvars
+ // these will be things like coop, skill, deathmatch, etc
+ while (true) {
+ name= f.readString();
+ if (name == null)
+ break;
+ string= f.readString();
+
+ Com.DPrintf("Set " + name + " = " + string + "\n");
+ Cvar.ForceSet(name, string);
+ }
- try {
f.close();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- // start a new game fresh with new cvars
- SV_InitGame();
+ // start a new game fresh with new cvars
+ SV_InitGame();
- svs.mapcmd = mapcmd;
+ svs.mapcmd= mapcmd;
- // read game state
- name = FS.Gamedir() + "/save/current/game.ssv";
- ge.ReadGame(name);
+ // read game state
+ filename= FS.Gamedir() + "/save/current/game.ssv";
+ GameSave.ReadGame(filename);
+ }
+ catch (Exception e) {
+ Com.Printf("Couldn't read file " + name + "\n");
+ e.printStackTrace();
+ }
}
//=========================================================
@@ -588,7 +560,7 @@ public class SV_CCMDS extends SV_ENTS {
FS.CreatePath(FS.Gamedir() + "/save/current/");
// check for clearing the current savegame
- map = Cmd.Argv(1);
+ map= Cmd.Argv(1);
if (map.charAt(0) == '*') {
// wipe all the *.sav files
SV_WipeSavegame("current");
@@ -598,22 +570,22 @@ public class SV_CCMDS extends SV_ENTS {
// 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++) {
- cl = svs.clients[i];
- savedInuse[i] = cl.edict.inuse;
- cl.edict.inuse = false;
+ savedInuse= new boolean[(int) maxclients.value];
+ for (i= 0; i < maxclients.value; i++) {
+ cl= svs.clients[i];
+ savedInuse[i]= cl.edict.inuse;
+ cl.edict.inuse= false;
}
SV_WriteLevelFile();
// we must restore these for clients to transfer over correctly
- for (i = 0; i < maxclients.value; i++) {
- cl = svs.clients[i];
- cl.edict.inuse = savedInuse[i];
+ for (i= 0; i < maxclients.value; i++) {
+ cl= svs.clients[i];
+ cl.edict.inuse= savedInuse[i];
}
- savedInuse = null;
+ savedInuse= null;
}
}
@@ -621,15 +593,12 @@ public class SV_CCMDS extends SV_ENTS {
SV_Map(false, Cmd.Argv(1), false);
// archive server state
- svs.mapcmd = Cmd.Argv(1);
+ svs.mapcmd= Cmd.Argv(1);
// copy off the level to the autosave slot
if (0 == dedicated.value) {
-
- //TODO: SV_WriteServerFile.
- //SV_WriteServerFile(true);
-
- //SV_CopySaveGame("current", "save0");
+ SV_WriteServerFile(true);
+ SV_CopySaveGame("current", "save0");
}
}
@@ -647,18 +616,19 @@ public class SV_CCMDS extends SV_ENTS {
String expanded;
// if not a pcx, demo, or cinematic, check to make sure the level exists
- map = Cmd.Argv(1);
- if (!strstr(map, ".")) {
- expanded = "maps/" + map + ".bsp";
+ map= Cmd.Argv(1);
+ if (map.indexOf(".") < 0) {
+ expanded= "maps/" + map + ".bsp";
if (FS.LoadFile(expanded) == null) {
+
Com.Printf("Can't find " + expanded + "\n");
return;
}
}
- sv.state = ss_dead; // don't save current level when changing
- //TODO: savegame
- //SV_WipeSavegame("current");
+ sv.state= ss_dead; // don't save current level when changing
+
+ SV_WipeSavegame("current");
SV_GameMap_f();
}
@@ -692,15 +662,15 @@ public class SV_CCMDS extends SV_ENTS {
Com.Printf("Loading game...\n");
- dir = Cmd.Argv(1);
+ dir= Cmd.Argv(1);
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";
+ name= FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv";
try {
- f = new RandomAccessFile(name, "r");
+ f= new RandomAccessFile(name, "r");
}
catch (FileNotFoundException e) {
Com.Printf("No such savegame: " + name + "\n");
@@ -719,7 +689,7 @@ public class SV_CCMDS extends SV_ENTS {
SV_ReadServerFile();
// go to the map
- sv.state = ss_dead; // don't save current level when changing
+ sv.state= ss_dead; // don't save current level when changing
SV_INIT.SV_Map(false, svs.mapcmd, true);
}
@@ -757,7 +727,7 @@ public class SV_CCMDS extends SV_ENTS {
return;
}
- dir = Cmd.Argv(1);
+ dir= Cmd.Argv(1);
if (strstr(dir, "..") || strstr(dir, "/") || strstr(dir, "\\")) {
Com.Printf("Bad savedir.\n");
}
@@ -811,7 +781,7 @@ public class SV_CCMDS extends SV_ENTS {
// SV_BroadcastPrintf message
SV_ClientPrintf(sv_client, PRINT_HIGH, "You were kicked from the game\n");
SV_DropClient(sv_client);
- sv_client.lastmessage = svs.realtime; // min case there is a funny zombie
+ sv_client.lastmessage= svs.realtime; // min case there is a funny zombie
}
/*
@@ -832,8 +802,8 @@ 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++) {
- cl = svs.clients[i];
+ for (i= 0; i < maxclients.value; i++) {
+ cl= svs.clients[i];
if (0 == cl.state)
continue;
@@ -845,21 +815,21 @@ public class SV_CCMDS extends SV_ENTS {
else if (cl.state == cs_zombie)
Com.Printf("ZMBI ");
else {
- ping = cl.ping < 9999 ? cl.ping : 9999;
+ ping= cl.ping < 9999 ? cl.ping : 9999;
Com.Printf("%4i ", new Vargs().add(ping));
}
Com.Printf("%s", new Vargs().add(cl.name));
- l = 16 - cl.name.length();
- for (j = 0; j < l; j++)
+ l= 16 - cl.name.length();
+ for (j= 0; j < l; j++)
Com.Printf(" ");
Com.Printf("%7i ", new Vargs().add(svs.realtime - cl.lastmessage));
- s = NET.AdrToString(cl.netchan.remote_address);
+ s= NET.AdrToString(cl.netchan.remote_address);
Com.Printf(s);
- l = 22 - s.length();
- for (j = 0; j < l; j++)
+ l= 22 - s.length();
+ for (j= 0; j < l; j++)
Com.Printf(" ");
Com.Printf("%5i", new Vargs().add(cl.netchan.qport));
@@ -883,17 +853,17 @@ public class SV_CCMDS extends SV_ENTS {
if (Cmd.Argc() < 2)
return;
- text = "console: ";
- p = Cmd.Args();
+ text= "console: ";
+ p= Cmd.Args();
if (p.charAt(0) == '"') {
- p = p.substring(1, p.length() - 1);
+ p= p.substring(1, p.length() - 1);
}
text += p;
- 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_spawned)
continue;
SV_ClientPrintf(client, PRINT_CHAT, text + "\n");
@@ -906,7 +876,7 @@ public class SV_CCMDS extends SV_ENTS {
==================
*/
public static void SV_Heartbeat_f() {
- svs.last_heartbeat = -9999999;
+ svs.last_heartbeat= -9999999;
}
/*
@@ -954,8 +924,8 @@ public class SV_CCMDS extends SV_ENTS {
public static void SV_ServerRecord_f() {
//char name[MAX_OSPATH];
String name;
- byte buf_data[] = new byte[32768];
- sizebuf_t buf = new sizebuf_t();
+ byte buf_data[]= new byte[32768];
+ sizebuf_t buf= new sizebuf_t();
int len;
int i;
@@ -977,12 +947,12 @@ public class SV_CCMDS extends SV_ENTS {
//
// open the demo file
//
- name = FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2";
+ name= FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2";
Com.Printf("recording to " + name + ".\n");
FS.CreatePath(name);
try {
- svs.demofile = new RandomAccessFile(name, "rw");
+ svs.demofile= new RandomAccessFile(name, "rw");
}
catch (Exception e) {
Com.Printf("ERROR: couldn't open.\n");
@@ -1012,7 +982,7 @@ public class SV_CCMDS extends SV_ENTS {
// send full levelname
MSG.WriteString(buf, sv.configstrings[CS_NAME]);
- for (i = 0; i < MAX_CONFIGSTRINGS; i++)
+ for (i= 0; i < MAX_CONFIGSTRINGS; i++)
if (sv.configstrings[i].length() == 0) {
MSG.WriteByte(buf, svc_configstring);
MSG.WriteShort(buf, i);
@@ -1021,7 +991,7 @@ public class SV_CCMDS extends SV_ENTS {
// write it to the demo file
Com.DPrintf("signon message length: " + buf.cursize + "\n");
- len = EndianHandler.swapInt(buf.cursize);
+ len= EndianHandler.swapInt(buf.cursize);
//fwrite(len, 4, 1, svs.demofile);
//fwrite(buf.data, buf.cursize, 1, svs.demofile);
try {
@@ -1054,7 +1024,7 @@ public class SV_CCMDS extends SV_ENTS {
catch (IOException e) {
e.printStackTrace();
}
- svs.demofile = null;
+ svs.demofile= null;
Com.Printf("Recording completed.\n");
}
@@ -1081,12 +1051,8 @@ public class SV_CCMDS extends SV_ENTS {
===============
*/
public static void SV_ServerCommand_f() {
- if (SV_GAME.ge == null) {
- Com.Printf("No game loaded.\n");
- return;
- }
- SV_GAME.ge.ServerCommand();
+ Game.ServerCommand();
}
//===========================================================
diff --git a/src/jake2/server/SV_ENTS.java b/src/jake2/server/SV_ENTS.java
index 6437dff..4082dbe 100644
--- a/src/jake2/server/SV_ENTS.java
+++ b/src/jake2/server/SV_ENTS.java
@@ -19,18 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_ENTS.java,v 1.2 2004-07-08 15:58:45 hzi Exp $
+// $Id: SV_ENTS.java,v 1.2.2.1 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
-import java.io.IOException;
-
-import jake2.*;
-import jake2.client.*;
import jake2.game.*;
import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.util.Vargs;
+
+import java.io.IOException;
public class SV_ENTS extends SV_USER {
@@ -383,7 +379,7 @@ public class SV_ENTS extends SV_USER {
for (i = 0; i < count; i++)
leafs[i] = CM.CM_LeafCluster(leafs[i]);
- memcpy(fatpvs, CM.CM_ClusterPVS(leafs[0]), longs << 2);
+ System.arraycopy(CM.CM_ClusterPVS(leafs[0]), 0, fatpvs, 0, longs << 2);
// or in all the other leaf bits
for (i = 1; i < count; i++) {
for (j = 0; j < i; j++)
@@ -460,8 +456,8 @@ public class SV_ENTS extends SV_USER {
c_fullsend = 0;
- for (e = 1; e < SV_GAME.ge.num_edicts; e++) {
- ent = SV_GAME.ge.edicts[e];
+ for (e = 1; e < GameBase.num_edicts; e++) {
+ ent = GameBase.g_edicts[e];
// ignore ents without visible models
if ((ent.svflags & SVF_NOCLIENT) != 0)
@@ -571,9 +567,9 @@ public class SV_ENTS extends SV_USER {
MSG.WriteByte(buf, svc_packetentities);
e = 1;
- ent = SV_GAME.ge.edicts[e];
+ ent = GameBase.g_edicts[e];
- while (e < SV_GAME.ge.num_edicts) {
+ while (e < GameBase.num_edicts) {
// ignore ents without visible models unless they have an effect
if (ent.inuse
&& ent.s.number != 0
@@ -582,7 +578,7 @@ public class SV_ENTS extends SV_USER {
MSG.WriteDeltaEntity(nostate, ent.s, buf, false, true);
e++;
- ent = SV_GAME.ge.edicts[e];
+ ent = GameBase.g_edicts[e];
}
MSG.WriteShort(buf, 0); // end of packetentities
diff --git a/src/jake2/server/SV_GAME.java b/src/jake2/server/SV_GAME.java
index 8a6e0ac..c54c069 100644
--- a/src/jake2/server/SV_GAME.java
+++ b/src/jake2/server/SV_GAME.java
@@ -19,22 +19,15 @@ 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.4.2.1 2004-07-09 08:38:25 hzi Exp $
+// $Id: SV_GAME.java,v 1.4.2.2 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
-import jake2.*;
-import jake2.client.*;
import jake2.game.*;
import jake2.qcommon.*;
-import jake2.render.*;
-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 +43,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 +65,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 +76,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 +99,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 +141,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
@@ -326,11 +292,7 @@ public class SV_GAME extends SV_INIT {
===============
*/
public static void SV_ShutdownGameProgs() {
- if (ge == null)
- return;
- ge.Shutdown();
- Sys.UnloadGame();
- ge = null;
+ Game.ShutdownGame();
}
/*
@@ -344,19 +306,13 @@ public class SV_GAME extends SV_INIT {
public static void SV_InitGameProgs() {
// unload anything we have now
- if (ge != null)
- SV_ShutdownGameProgs();
+ SV_ShutdownGameProgs();
game_import_t gimport = new game_import_t();
// all functions set in game_export_t (rst)
- ge = GameBase.GetGameApi(gimport);
-
- if (ge == null)
- Com.Error(ERR_DROP, "failed to load game DLL");
- if (ge.apiversion != GAME_API_VERSION)
- Com.Error(ERR_DROP, "game is version " + ge.apiversion + " not " + GAME_API_VERSION);
+ GameBase.GetGameApi(gimport);
- ge.Init();
+ Game.InitGame();
}
}
diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java
index 533fe8b..88a1352 100644
--- a/src/jake2/server/SV_INIT.java
+++ b/src/jake2/server/SV_INIT.java
@@ -19,25 +19,24 @@ 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.3.2.1 2004-07-09 08:38:24 hzi Exp $
+// $Id: SV_INIT.java,v 1.3.2.2 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-import jake2.*;
-import jake2.client.*;
+import jake2.Globals;
+import jake2.client.CL;
+import jake2.client.SCR;
import jake2.game.*;
import jake2.qcommon.*;
-import jake2.render.*;
import jake2.sys.NET;
-import jake2.util.Lib;
-public class SV_INIT extends Globals {
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+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
+ public static server_static_t svs= new server_static_t(); // persistant server info
+ public static server_t sv= new server_t(); // local server
/*
================
@@ -51,7 +50,7 @@ public class SV_INIT extends Globals {
if (name == null || name.length() == 0)
return 0;
- for (i = 1; i < max && sv.configstrings[start + i] != null; i++)
+ for (i= 1; i < max && sv.configstrings[start + i] != null; i++)
if (0 == strcmp(sv.configstrings[start + i], name))
return i;
@@ -62,7 +61,7 @@ public class SV_INIT extends Globals {
Com.Error(ERR_DROP, "*Index: overflow");
//strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i]));
- sv.configstrings[start + i] = name;
+ sv.configstrings[start + i]= name;
if (sv.state != ss_loading) { // send the update to everyone
SZ.Clear(sv.multicast);
@@ -100,22 +99,22 @@ public class SV_INIT extends Globals {
edict_t svent;
int entnum;
- for (entnum = 1; entnum < SV_GAME.ge.num_edicts; entnum++) {
+ for (entnum= 1; entnum < GameBase.num_edicts; entnum++) {
//svent = EDICT_NUM(entnum);
- svent = SV_GAME.ge.edicts[entnum];
+ svent= GameBase.g_edicts[entnum];
if (!svent.inuse)
continue;
if (0 == svent.s.modelindex && 0 == svent.s.sound && 0 == svent.s.effects)
continue;
- svent.s.number = entnum;
+ svent.s.number= entnum;
//
// take current state as baseline
//
VectorCopy(svent.s.origin, svent.s.old_origin);
// rst: bugfix
- sv.baselines[entnum].set(svent.s);// = svent.s.getClone();
+ sv.baselines[entnum].set(svent.s); // = svent.s.getClone();
}
}
@@ -125,9 +124,8 @@ public class SV_INIT extends Globals {
=================
*/
public static void SV_CheckForSavegame() {
- //char name[MAX_OSPATH];
+
String name;
- //FILE *f;
RandomAccessFile f;
int i;
@@ -138,13 +136,13 @@ public class SV_INIT extends Globals {
if (Cvar.VariableValue("deathmatch") != 0)
return;
- name = FS.Gamedir() + "/save/current/" + sv.name + ".sav";
+ name= FS.Gamedir() + "/save/current/" + sv.name + ".sav";
try {
- f = new RandomAccessFile(name, "r");
+ f= new RandomAccessFile(name, "r");
}
catch (Exception e) {
- return; // no savegame
+ return;
}
try {
@@ -167,12 +165,12 @@ public class SV_INIT extends Globals {
// prevents these from being passed down.
int previousState; // PGM
- previousState = sv.state; // PGM
- sv.state = ss_loading; // PGM
- for (i = 0; i < 100; i++)
- SV_GAME.ge.RunFrame();
+ previousState= sv.state; // PGM
+ sv.state= ss_loading; // PGM
+ for (i= 0; i < 100; i++)
+ Game.G_RunFrame();
- sv.state = previousState; // PGM
+ sv.state= previousState; // PGM
}
}
@@ -185,14 +183,9 @@ 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;
+ int checksum= 0;
if (attractloop)
Cvar.Set("paused", "0");
@@ -209,68 +202,69 @@ public class SV_INIT extends Globals {
svs.spawncount++; // any partially connected client will be
// restarted
- sv.state = ss_dead;
-
- Com.SetServerState(sv.state);
+
+ sv.state= ss_dead;
+
+ Globals.server_state= sv.state;
// wipe the entire per-level structure
//memset(sv, 0, sizeof(sv));
- sv = new server_t();
-
- svs.realtime = 0;
- sv.loadgame = loadgame;
- sv.attractloop = attractloop;
+ sv= new server_t();
+
+ svs.realtime= 0;
+ sv.loadgame= loadgame;
+ sv.attractloop= attractloop;
// save name for levels that don't set message
sv.configstrings[CS_NAME]= server;
-
- if (Cvar.VariableValue("deathmatch")!=0) {
- sv.configstrings[CS_AIRACCEL] = ""+SV_MAIN.sv_airaccelerate.value;
- PMove.pm_airaccelerate = SV_MAIN.sv_airaccelerate.value;
+
+ if (Cvar.VariableValue("deathmatch") != 0) {
+ sv.configstrings[CS_AIRACCEL]= "" + SV_MAIN.sv_airaccelerate.value;
+ PMove.pm_airaccelerate= SV_MAIN.sv_airaccelerate.value;
}
else {
- sv.configstrings[CS_AIRACCEL] = "0";
- PMove.pm_airaccelerate = 0;
+ sv.configstrings[CS_AIRACCEL]= "0";
+ PMove.pm_airaccelerate= 0;
}
SZ.Init(sv.multicast, sv.multicast_buf, sv.multicast_buf.length);
- sv.name = server;
+ 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;
- svs.clients[i].lastframe = -1;
+ svs.clients[i].state= cs_connected;
+ svs.clients[i].lastframe= -1;
}
- sv.time = 1000;
+ sv.time= 1000;
- sv.name=server;
- sv.configstrings[CS_NAME] = server;
-
- int iw[] = {checksum};
+ sv.name= server;
+ sv.configstrings[CS_NAME]= server;
+
+ int iw[]= { checksum };
if (serverstate != ss_game) {
- sv.models[1] = CM.CM_LoadMap("", false, iw); // no real map
+ sv.models[1]= CM.CM_LoadMap("", false, iw); // no real map
}
else {
- sv.configstrings[CS_MODELS + 1] = "maps/" + server + ".bsp";
- sv.models[1] = CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw);
+ sv.configstrings[CS_MODELS + 1]= "maps/" + server + ".bsp";
+ sv.models[1]= CM.CM_LoadMap(sv.configstrings[CS_MODELS + 1], false, iw);
}
- checksum = iw[0];
- sv.configstrings[CS_MAPCHECKSUM] = "" + checksum;
+ checksum= iw[0];
+ sv.configstrings[CS_MAPCHECKSUM]= "" + checksum;
//
// clear physics interaction links
//
SV_WORLD.SV_ClearWorld();
- for (i = 1; i < CM.CM_NumInlineModels(); i++) {
- sv.configstrings[CS_MODELS + 1 + i] = "*" + 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]);
+ sv.models[i + 1]= CM.InlineModel(sv.configstrings[CS_MODELS + 1 + i]);
}
//
@@ -279,19 +273,20 @@ public class SV_INIT extends Globals {
// precache and static commands can be issued during
// map initialization
- sv.state = ss_loading;
- Com.SetServerState(sv.state);
+
+ sv.state= ss_loading;
+ Globals.server_state= sv.state;
// load and spawn all other entities
- SV_GAME.ge.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint);
+ Game.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint);
// run two frames to allow everything to settle
- SV_GAME.ge.RunFrame();
- SV_GAME.ge.RunFrame();
+ Game.G_RunFrame();
+ Game.G_RunFrame();
// all precaches are complete
- sv.state = serverstate;
- Com.SetServerState(sv.state);
+ sv.state= serverstate;
+ Globals.server_state= sv.state;
// create a baseline for more efficient communications
SV_CreateBaseline();
@@ -314,7 +309,7 @@ public class SV_INIT extends Globals {
*/
public static void SV_InitGame() {
int i;
- edict_t ent;
+ edict_t ent;
//char idmaster[32];
String idmaster;
@@ -331,28 +326,28 @@ public class SV_INIT extends Globals {
// get any latched variable changes (maxclients, etc)
Cvar.GetLatchedVars();
- svs.initialized = true;
+ 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 (0==Cvar.VariableValue("coop"))
+ 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);
+ 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);
@@ -362,37 +357,37 @@ public class SV_INIT extends Globals {
Cvar.FullSet("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH);
}
- svs.spawncount = rand();
+ svs.spawncount= rand();
//svs.clients = Z_Malloc(sizeof(client_t) * maxclients.value);
- svs.clients = new client_t[(int) SV_MAIN.maxclients.value];
- for (int n=0; n < svs.clients.length; n++)
+ svs.clients= new client_t[(int) SV_MAIN.maxclients.value];
+ for (int n= 0; n < svs.clients.length; n++)
svs.clients[n]= new client_t();
-
- svs.num_client_entities = ((int) SV_MAIN.maxclients.value) * UPDATE_BACKUP * 64; //ok.
-
+
+ svs.num_client_entities= ((int) SV_MAIN.maxclients.value) * UPDATE_BACKUP * 64; //ok.
+
//svs.client_entities = Z_Malloc(sizeof(entity_state_t) * svs.num_client_entities);
- svs.client_entities = new entity_state_t[svs.num_client_entities];
- for (int n=0; n < svs.client_entities.length; n++)
- svs.client_entities[n] = new entity_state_t(null);
+ svs.client_entities= new entity_state_t[svs.num_client_entities];
+ for (int n= 0; n < svs.client_entities.length; n++)
+ svs.client_entities[n]= new entity_state_t(null);
// init network stuff
NET.Config((SV_MAIN.maxclients.value > 1)); //ok!
// heartbeats will always be sent to the id master
- svs.last_heartbeat = -99999; // send immediately
- idmaster = "192.246.40.37:" + PORT_MASTER;
+ svs.last_heartbeat= -99999; // send immediately
+ idmaster= "192.246.40.37:" + PORT_MASTER;
NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]);
// init game
SV_GAME.SV_InitGameProgs(); // bis hier alles ok!
-
- for (i = 0; i < SV_MAIN.maxclients.value; i++) {
- ent = SV_GAME.ge.edicts[i + 1];
-
+
+ for (i= 0; i < SV_MAIN.maxclients.value; i++) {
+ ent= GameBase.g_edicts[i + 1];
+
//ent.s.number = i + 1; //dont need this, ent.s.number already set.
- svs.clients[i].edict = ent;
+ svs.clients[i].edict= ent;
//memset(& svs.clients[i].lastcmd, 0, sizeof(svs.clients[i].lastcmd));
- svs.clients[i].lastcmd = new usercmd_t();
+ svs.clients[i].lastcmd= new usercmd_t();
}
}
@@ -420,13 +415,13 @@ public class SV_INIT extends Globals {
String level, ch, spawnpoint;
- sv.loadgame = loadgame;
- sv.attractloop = attractloop;
+ sv.loadgame= loadgame;
+ sv.attractloop= attractloop;
if (sv.state == ss_dead && !sv.loadgame)
SV_InitGame(); // the game is just starting
- level = levelstring; // bis hier her ok.
+ level= levelstring; // bis hier her ok.
// if there is a + in the map, set nextserver to the remainder
@@ -440,36 +435,36 @@ public class SV_INIT extends Globals {
// else
// Cvar_Set ("nextserver", "");
- int c = level.indexOf('+');
+ int c= level.indexOf('+');
if (c != -1) {
- Cvar.Set("nextserver","gamemap \"" + level.substring(c+1) + "\"");
- level = level.substring(0, c);
+ Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\"");
+ level= level.substring(0, c);
}
else {
Cvar.Set("nextserver", "");
}
//ZOID special hack for end game screen in coop mode
- if (Cvar.VariableValue("coop")!=0 && !level.equals( "victory.pcx"))
+ if (Cvar.VariableValue("coop") != 0 && !level.equals("victory.pcx"))
Cvar.Set("nextserver", "gamemap \"*base1\"");
// if there is a $, use the remainder as a spawnpoint
- int pos = level.indexOf('$');
- if (pos!=-1) {
+ int pos= level.indexOf('$');
+ if (pos != -1) {
//* ch = 0;
- spawnpoint = level.substring(pos + 1);
- level = level.substring(0,pos);
-
+ spawnpoint= level.substring(pos + 1);
+ level= level.substring(0, pos);
+
}
else
//spawnpoint[0] = 0;
- spawnpoint = "";
+ spawnpoint= "";
// skip the end-of-unit flag if necessary
if (level.charAt(0) == '*')
- level = level.substring(1);
+ level= level.substring(1);
- l = level.length();
+ l= level.length();
if (l > 4 && level.endsWith(".cin")) {
SCR.BeginLoadingPlaque(); // for local system
SV_SEND.SV_BroadcastCommand("changing\n");
diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java
index 15d190e..a45b1e6 100644
--- a/src/jake2/server/SV_MAIN.java
+++ b/src/jake2/server/SV_MAIN.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: SV_MAIN.java,v 1.2.2.1 2004-07-09 08:38:25 hzi Exp $
+// $Id: SV_MAIN.java,v 1.2.2.2 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
@@ -89,7 +89,7 @@ public class SV_MAIN extends SV_GAME {
if (drop.state == Defines.cs_spawned) {
// call the prog function for removing a client
// this will remove the body, among other things
- SV_GAME.ge.ClientDisconnect(drop.edict);
+ PlayerClient.ClientDisconnect(drop.edict);
}
if (drop.download != null) {
@@ -363,12 +363,12 @@ public class SV_MAIN extends SV_GAME {
sv_client = svs.clients[i];
//edictnum = (newcl-svs.clients)+1;
int edictnum = i + 1;
- edict_t ent = ge.edicts[edictnum];
+ edict_t ent = GameBase.g_edicts[edictnum];
svs.clients[i].edict = ent;
svs.clients[i].challenge = challenge; // save challenge for checksumming
// get the game a chance to reject this connection or modify the userinfo
- if (!(ge.ClientConnect(ent, userinfo))) {
+ if (!(PlayerClient.ClientConnect(ent, userinfo))) {
if (Info.Info_ValueForKey(userinfo, "rejmsg") != null)
Netchan.OutOfBandPrint(
NS_SERVER,
@@ -444,8 +444,8 @@ public class SV_MAIN extends SV_GAME {
remaining = "";
for (i = 2; i < Cmd.Argc(); i++) {
- strcat(remaining, Cmd.Argv(i));
- strcat(remaining, " ");
+ remaining += Cmd.Argv(i);
+ remaining += " ";
}
Cmd.ExecuteString(remaining);
@@ -670,8 +670,8 @@ public class SV_MAIN extends SV_GAME {
edict_t ent;
int i;
- for (i = 0; i < ge.num_edicts; i++) {
- ent = SV_GAME.ge.edicts[i];
+ for (i = 0; i < GameBase.num_edicts; i++) {
+ ent = GameBase.g_edicts[i];
// events only last for a single message
ent.s.event = 0;
}
@@ -696,7 +696,7 @@ public class SV_MAIN extends SV_GAME {
// don't run if paused
if (0 == sv_paused.value || maxclients.value > 1) {
- ge.RunFrame();
+ Game.G_RunFrame();
// never get more than one tic behind
if (sv.time < svs.realtime) {
@@ -862,7 +862,7 @@ public class SV_MAIN extends SV_GAME {
int i;
// call prog code to allow overrides
- SV_GAME.ge.ClientUserinfoChanged(cl.edict, cl.userinfo);
+ PlayerClient.ClientUserinfoChanged(cl.edict, cl.userinfo);
// name for C code
cl.name = Info.Info_ValueForKey(cl.userinfo, "name");
@@ -1006,9 +1006,8 @@ public class SV_MAIN extends SV_GAME {
//memset (&sv, 0, sizeof(sv));
sv = new server_t();
-
- Com.SetServerState (sv.state);
+ Globals.server_state= sv.state;
// free server static data
//if (svs.clients!=null)
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index 0764ce6..f117b9c 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.3.2.1 2004-09-06 19:39:18 hzi 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/SV_USER.java b/src/jake2/server/SV_USER.java
index d05c2fb..7d37c90 100644
--- a/src/jake2/server/SV_USER.java
+++ b/src/jake2/server/SV_USER.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_USER.java,v 1.3.2.1 2004-07-09 08:38:25 hzi Exp $
+// $Id: SV_USER.java,v 1.3.2.2 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
@@ -124,7 +124,7 @@ public class SV_USER extends SV_SEND
if (sv.state == ss_game)
{
// set up the entity for the client
- ent= SV_GAME.ge.edicts[playernum + 1];
+ ent= GameBase.g_edicts[playernum + 1];
ent.s.number= playernum + 1;
sv_client.edict= ent;
sv_client.lastcmd= new usercmd_t();
@@ -269,7 +269,7 @@ public class SV_USER extends SV_SEND
sv_client.state= cs_spawned;
// call the game begin function
- SV_GAME.ge.ClientBegin(sv_player);
+ PlayerClient.ClientBegin(sv_player);
Cbuf.InsertFromDefer();
}
@@ -552,7 +552,7 @@ public class SV_USER extends SV_SEND
}
if (i == ucmds.length && sv.state == ss_game)
- SV_GAME.ge.ClientCommand(sv_player);
+ PlayerClient.ClientCommand(sv_player);
// SV_EndRedirect ();
}
@@ -575,7 +575,7 @@ public class SV_USER extends SV_SEND
return;
}
- SV_GAME.ge.ClientThink(cl.edict, cmd);
+ PlayerClient.ClientThink(cl.edict, cmd);
}
public static final int MAX_STRINGCMDS= 8;
diff --git a/src/jake2/server/SV_WORLD.java b/src/jake2/server/SV_WORLD.java
index 2015a44..e2dda33 100644
--- a/src/jake2/server/SV_WORLD.java
+++ b/src/jake2/server/SV_WORLD.java
@@ -19,19 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 07.01.2000 by RST.
-// $Id: SV_WORLD.java,v 1.3.2.1 2004-07-09 08:38:25 hzi Exp $
+// $Id: SV_WORLD.java,v 1.3.2.2 2004-09-06 19:39:18 hzi Exp $
package jake2.server;
-import jake2.game.edict_t;
-import jake2.game.trace_t;
-
-import jake2.*;
-import jake2.client.*;
import jake2.game.*;
-import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.util.Vargs;
+import jake2.qcommon.CM;
+import jake2.qcommon.Com;
public class SV_WORLD extends SV_CCMDS
{
@@ -176,6 +170,7 @@ public class SV_WORLD extends SV_CCMDS
{
if (null == ent.area.prev)
return; // not linked in anywhere
+
RemoveLink(ent.area);
ent.area.prev= ent.area.next= null;
}
@@ -201,7 +196,7 @@ public class SV_WORLD extends SV_CCMDS
if (ent.area.prev != null)
SV_UnlinkEdict(ent); // unlink from old position
- if (ent == ge.edicts[0])
+ if (ent == GameBase.g_edicts[0])
return; // don't add the world
if (!ent.inuse)
@@ -212,7 +207,8 @@ public class SV_WORLD extends SV_CCMDS
// encode the size into the entity_state for client prediction
if (ent.solid == SOLID_BBOX && 0 == (ent.svflags & SVF_DEADMONSTER))
- { // assume that x/y are equal and symetric
+ {
+ // assume that x/y are equal and symetric
int i= (int) (ent.maxs[0] / 8);
if (i < 1)
i= 1;
@@ -244,7 +240,8 @@ public class SV_WORLD extends SV_CCMDS
// set the abs box
if (ent.solid == SOLID_BSP && (ent.s.angles[0] != 0 || ent.s.angles[1] != 0 || ent.s.angles[2] != 0))
- { // expand for rotation
+ {
+ // expand for rotation
float max, v;
max= 0;
@@ -264,7 +261,8 @@ public class SV_WORLD extends SV_CCMDS
}
}
else
- { // normal
+ {
+ // normal
VectorAdd(ent.s.origin, ent.mins, ent.absmin);
VectorAdd(ent.s.origin, ent.maxs, ent.absmax);
}
@@ -284,7 +282,7 @@ public class SV_WORLD extends SV_CCMDS
ent.areanum= 0;
ent.areanum2= 0;
- //get all leafs, including solids
+ // get all leafs, including solids
int iw[] = {topnode};
@@ -659,7 +657,7 @@ public class SV_WORLD extends SV_CCMDS
// clip to world
clip.trace= CM.BoxTrace(start, end, mins, maxs, 0, contentmask);
- clip.trace.ent= ge.edicts[0];
+ clip.trace.ent= GameBase.g_edicts[0];
if (clip.trace.fraction == 0)
return clip.trace; // blocked by the world
diff --git a/src/jake2/server/client_t.java b/src/jake2/server/client_t.java
index 2bbadf9..f52dd39 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.1.2.1 2004-09-06 19:39:18 hzi 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;
}
diff --git a/src/jake2/server/scrap.jpage b/src/jake2/server/scrap.jpage
deleted file mode 100644
index 1666502..0000000
--- a/src/jake2/server/scrap.jpage
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-String p="\"123456\"";
-
-System.out.println(p.substring(1,p.length()-1));
-
- String path ="c:/baseq2/game/*.sav";
- String findbase;
- String findpattern;
-
- int i = path.lastIndexOf('/');
- if (i!=-1)
- {
- findbase = path.substring(0,i);
- findpattern = path.substring(i+1,path.length());
- }
- else
- {
- findpattern = "*";
- findbase = path;
- }
-
-
- System.out.println(findbase + ":" + findpattern); \ No newline at end of file