diff options
-rw-r--r-- | src/jake2/Defines.java | 13 | ||||
-rw-r--r-- | src/jake2/game/GameAI.java | 289 | ||||
-rw-r--r-- | src/jake2/game/GameUtil.java | 120 | ||||
-rw-r--r-- | src/jake2/game/Info.java | 72 | ||||
-rw-r--r-- | src/jake2/game/PlayerClient.java | 195 | ||||
-rw-r--r-- | src/jake2/game/PlayerView.java | 97 | ||||
-rw-r--r-- | src/jake2/qcommon/Cvar.java | 86 | ||||
-rw-r--r-- | src/jake2/qcommon/PMove.java | 858 | ||||
-rw-r--r-- | src/jake2/server/SV_ENTS.java | 57 | ||||
-rw-r--r-- | src/jake2/server/SV_MAIN.java | 204 | ||||
-rw-r--r-- | src/jake2/sys/NET.java | 98 | ||||
-rw-r--r-- | test/jake2/qcommon/TestINFO.java | 4 |
12 files changed, 857 insertions, 1236 deletions
diff --git a/src/jake2/Defines.java b/src/jake2/Defines.java index 9a80222..978bca6 100644 --- a/src/jake2/Defines.java +++ b/src/jake2/Defines.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: Defines.java,v 1.7 2005-12-16 21:13:42 salomo Exp $ +// $Id: Defines.java,v 1.8 2005-12-27 21:02:30 salomo Exp $ /** Contains the definitions for the game engine. */ @@ -1336,18 +1336,7 @@ public class Defines { public static final float MOVE_STOP_EPSILON = 0.1f; - - /* - ================== - PM_StepSlideMove - - Each intersection will try to step over the obstruction instead of - sliding along it. - Returns a new origin, velocity, and contact entity - Does not modify any world state? - ================== - */ public final static float MIN_STEP_NORMAL = 0.7f; // can't step up onto very steep slopes diff --git a/src/jake2/game/GameAI.java b/src/jake2/game/GameAI.java index 97e9868..457a0be 100644 --- a/src/jake2/game/GameAI.java +++ b/src/jake2/game/GameAI.java @@ -20,7 +20,7 @@ // Created on 02.11.2003 by RST. -// $Id: GameAI.java,v 1.9 2005-11-20 22:18:33 salomo Exp $ +// $Id: GameAI.java,v 1.10 2005-12-27 21:02:30 salomo Exp $ package jake2.game; @@ -37,11 +37,8 @@ public class GameAI { self.monsterinfo.attack_finished = GameBase.level.time + time; } - /* - * ============= ai_turn - * - * don't move, but turn towards ideal_yaw Distance is for slight position - * adjustments needed by the animations ============= + /** Don't move, but turn towards ideal_yaw Distance is for slight position + * adjustments needed by the animations. */ public static void ai_turn(edict_t self, float dist) { if (dist != 0) @@ -52,33 +49,9 @@ public class GameAI { M.M_ChangeYaw(self); } - - /* - * - * .enemy Will be world if not currently angry at anyone. - * - * .movetarget The next path spot to walk toward. If .enemy, ignore - * .movetarget. When an enemy is killed, the monster will try to return to - * it's path. - * - * .hunt_time Set to time + something when the player is in sight, but - * movement straight for him is blocked. This causes the monster to use wall - * following code for movement direction instead of sighting on the player. - * - * .ideal_yaw A yaw angle of the intended direction, which will be turned - * towards at up to 45 deg / state. If the enemy is in view and hunt_time is - * not active, this will be the exact line towards the enemy. - * - * .pausetime A monster will leave it's stand state and head towards it's - * .movetarget when time > .pausetime. - * - * walkmove(angle, speed) primitive is all or nothing - */ - - /* - * ============ FacingIdeal - * - * ============ + + /** + * Checks, if the monster should turn left/right. */ public static boolean FacingIdeal(edict_t self) { @@ -90,11 +63,8 @@ public class GameAI { return true; } - /* - * ============= ai_run_melee - * - * Turn and close until within an angle to launch a melee attack - * ============= + /** + * Turn and close until within an angle to launch a melee attack. */ public static void ai_run_melee(edict_t self) { self.ideal_yaw = enemy_yaw; @@ -106,11 +76,8 @@ public class GameAI { } } - /* - * ============= ai_run_missile - * - * Turn in place until within an angle to launch a missile attack - * ============= + /** + * Turn in place until within an angle to launch a missile attack. */ public static void ai_run_missile(edict_t self) { self.ideal_yaw = enemy_yaw; @@ -122,10 +89,8 @@ public class GameAI { } }; - /* - * ============= ai_run_slide - * - * Strafe sideways, but stay at aproximately the same range ============= + /** + * Strafe sideways, but stay at aproximately the same range. */ public static void ai_run_slide(edict_t self, float distance) { float ofs; @@ -145,18 +110,35 @@ public class GameAI { M.M_walkmove(self, self.ideal_yaw - ofs, distance); } - /* - * ============= ai_checkattack - * + /** * Decides if we're going to attack or do something else used by ai_run and - * ai_stand ============= + * ai_stand. + * + * .enemy Will be world if not currently angry at anyone. + * + * .movetarget The next path spot to walk toward. If .enemy, ignore + * .movetarget. When an enemy is killed, the monster will try to return to + * it's path. + * + * .hunt_time Set to time + something when the player is in sight, but + * movement straight for him is blocked. This causes the monster to use wall + * following code for movement direction instead of sighting on the player. + * + * .ideal_yaw A yaw angle of the intended direction, which will be turned + * towards at up to 45 deg / state. If the enemy is in view and hunt_time is + * not active, this will be the exact line towards the enemy. + * + * .pausetime A monster will leave it's stand state and head towards it's + * .movetarget when time > .pausetime. + * + * walkmove(angle, speed) primitive is all or nothing */ public static boolean ai_checkattack(edict_t self, float dist) { float temp[] = { 0, 0, 0 }; boolean hesDeadJim; - // this causes monsters to run blindly to the combat point w/o firing + // this causes monsters to run blindly to the combat point w/o firing if (self.goalentity != null) { if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0) return false; @@ -180,7 +162,7 @@ public class GameAI { enemy_vis = false; - // see if the enemy is dead + // see if the enemy is dead hesDeadJim = false; if ((null == self.enemy) || (!self.enemy.inuse)) { hesDeadJim = true; @@ -223,9 +205,8 @@ public class GameAI { } self.show_hostile = (int) GameBase.level.time + 1; // wake up other - // monsters - - // check knowledge of enemy + + // monsters check knowledge of enemy enemy_vis = GameUtil.visible(self, self.enemy); if (enemy_vis) { self.monsterinfo.search_time = GameBase.level.time + 5; @@ -233,13 +214,6 @@ public class GameAI { self.monsterinfo.last_sighting); } - // look for other coop players here - // if (coop && self.monsterinfo.search_time < level.time) - // { - // if (FindTarget (self)) - // return true; - // } - enemy_infront = GameUtil.infront(self, self.enemy); enemy_range = GameUtil.range(self, self.enemy); Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, temp); @@ -265,7 +239,6 @@ public class GameAI { /** * The monster is walking it's beat. - * */ static void ai_walk(edict_t self, float dist) { M.M_MoveToGoal(self, dist); @@ -287,17 +260,13 @@ public class GameAI { } } - /* - * ================= - * AI_SetSightClient - * + /** * Called once each frame to set level.sight_client to the player to be * checked for in findtarget. * * If all clients are either dead or in notarget, sight_client will be null. * * In coop games, sight_client will cycle between the clients. - * ================= */ static void AI_SetSightClient() { edict_t ent; @@ -327,20 +296,18 @@ public class GameAI { } } - /* - * ============= - * ai_move - * + /** * Move the specified distance at current facing. This replaces the QC * functions: ai_forward, ai_back, ai_pain, and ai_painforward - * ============== */ static void ai_move(edict_t self, float dist) { M.M_walkmove(self, self.s.angles[Defines.YAW], dist); } - // ============================================================================ - //ok + + /** + * Decides running or standing according to flag AI_STAND_GROUND. + */ static void HuntTarget(edict_t self) { float[] vec = { 0, 0, 0 }; @@ -351,11 +318,13 @@ public class GameAI { self.monsterinfo.run.think(self); Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, vec); self.ideal_yaw = Math3D.vectoyaw(vec); + // wait a while before first attack if (0 == (self.monsterinfo.aiflags & Defines.AI_STAND_GROUND)) GameUtil.AttackFinished(self, 1); } + public static EntThinkAdapter walkmonster_start_go = new EntThinkAdapter() { public String getID() { return "walkmonster_start_go"; } public boolean think(edict_t self) { @@ -446,12 +415,10 @@ public class GameAI { } }; - /* - * ============= ai_turn - * - * don't move, but turn towards ideal_yaw Distance is for slight position + + /** + * Don't move, but turn towards ideal_yaw Distance is for slight position * adjustments needed by the animations - * ============= */ public static AIAdapter ai_turn = new AIAdapter() { public String getID() { return "ai_turn";} @@ -467,13 +434,10 @@ public class GameAI { } }; - /* - * ============= - * ai_move - * + + /** * Move the specified distance at current facing. This replaces the QC * functions: ai_forward, ai_back, ai_pain, and ai_painforward - * ============== */ public static AIAdapter ai_move = new AIAdapter() { public String getID() { return "ai_move";} @@ -482,19 +446,13 @@ public class GameAI { } }; - /* - * ============= - * ai_walk - * - * The monster is walking it's beat - * ============= + + /** + * The monster is walking it's beat. */ public static AIAdapter ai_walk = new AIAdapter() { public String getID() { return "ai_walk";} public void ai(edict_t self, float dist) { - if (self.index == 312) - self.index = 312; - M.M_MoveToGoal(self, dist); // check for noticing a player @@ -505,23 +463,18 @@ public class GameAI { && (GameBase.level.time > self.monsterinfo.idle_time)) { if (self.monsterinfo.idle_time != 0) { self.monsterinfo.search.think(self); - self.monsterinfo.idle_time = GameBase.level.time + 15 - + Globals.rnd.nextFloat() * 15; + self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; } else { - self.monsterinfo.idle_time = GameBase.level.time - + Globals.rnd.nextFloat() * 15; + self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15; } } } }; - /* - * ============= - * ai_stand - * + + /** * Used for standing around and looking for players Distance is for slight - * position adjustments needed by the animations - * ============== + * position adjustments needed by the animations. */ public static AIAdapter ai_stand = new AIAdapter() { @@ -534,9 +487,7 @@ public class GameAI { if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) { if (self.enemy != null) { - Math3D - .VectorSubtract(self.enemy.s.origin, self.s.origin, - v); + Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, v); self.ideal_yaw = Math3D.vectoyaw(v); if (self.s.angles[Defines.YAW] != self.ideal_yaw && 0 != (self.monsterinfo.aiflags & Defines.AI_TEMP_STAND_GROUND)) { @@ -562,23 +513,17 @@ public class GameAI { && (GameBase.level.time > self.monsterinfo.idle_time)) { if (self.monsterinfo.idle_time != 0) { self.monsterinfo.idle.think(self); - self.monsterinfo.idle_time = GameBase.level.time + 15 - + Globals.rnd.nextFloat() * 15; + self.monsterinfo.idle_time = GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15; } else { - self.monsterinfo.idle_time = GameBase.level.time - + Globals.rnd.nextFloat() * 15; + self.monsterinfo.idle_time = GameBase.level.time + Globals.rnd.nextFloat() * 15; } } } }; - /* - * ============= - * ai_charge - * + /** * Turns towards target and advances Use this call with a distnace of 0 to - * replace ai_face - * ============== + * replace ai_face. */ public static AIAdapter ai_charge = new AIAdapter() { public String getID() { return "ai_charge";} @@ -594,12 +539,9 @@ public class GameAI { } }; - /* - * ============= - * ai_run - * - * The monster has an enemy it is trying to kill - * ============= + + /** + * The monster has an enemy it is trying to kill. */ public static AIAdapter ai_run = new AIAdapter() { public String getID() { return "ai_run";} @@ -622,7 +564,6 @@ public class GameAI { return; } - // rst: monster heard a sound.... if ((self.monsterinfo.aiflags & Defines.AI_SOUND_TARGET) != 0) { Math3D.VectorSubtract(self.s.origin, self.enemy.s.origin, v); // ...and reached it @@ -652,17 +593,16 @@ public class GameAI { } if (enemy_vis) { - // if (self.aiflags & AI_LOST_SIGHT) - // dprint("regained sight\n"); + //if (self.aiflags & AI_LOST_SIGHT) + // dprint("regained sight\n"); M.M_MoveToGoal(self, dist); self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT; - Math3D.VectorCopy(self.enemy.s.origin, - self.monsterinfo.last_sighting); + Math3D.VectorCopy(self.enemy.s.origin, self.monsterinfo.last_sighting); self.monsterinfo.trail_time = GameBase.level.time; return; } - // coop will change to another enemy if visible^ + // coop will change to another enemy if visible if (GameBase.coop.value != 0) { // FIXME: insane guys get mad with this, which causes crashes! if (GameUtil.FindTarget(self)) @@ -686,8 +626,9 @@ public class GameAI { if (0 == (self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT)) { // just lost sight of the player, decide where to go first - // dprint("lost sight of player, last seen at "); - // dprint(vtos(self.last_sighting)); dprint("\n"); + // dprint("lost sight of player, last seen at "); + // dprint(vtos(self.last_sighting)); + // dprint("\n"); self.monsterinfo.aiflags |= (Defines.AI_LOST_SIGHT | Defines.AI_PURSUIT_LAST_SEEN); self.monsterinfo.aiflags &= ~(Defines.AI_PURSUE_NEXT | Defines.AI_PURSUE_TEMP); new1 = true; @@ -695,8 +636,12 @@ public class GameAI { if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_NEXT) != 0) { self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_NEXT; - // dprint("reached current goal: "); dprint(vtos(self.origin)); - // dprint(" "); dprint(vtos(self.last_sighting)); dprint(" "); + + // dprint("reached current goal: "); + // dprint(vtos(self.origin)); + // dprint(" "); + // dprint(vtos(self.last_sighting)); + // dprint(" "); // dprint(ftos(vlen(self.origin - self.last_sighting))); // dprint("\n"); @@ -704,11 +649,10 @@ public class GameAI { self.monsterinfo.search_time = GameBase.level.time + 5; if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_TEMP) != 0) { - // dprint("was temp goal; retrying original\n"); + // dprint("was temp goal; retrying original\n"); self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_TEMP; marker = null; - Math3D.VectorCopy(self.monsterinfo.saved_goal, - self.monsterinfo.last_sighting); + Math3D.VectorCopy(self.monsterinfo.saved_goal, self.monsterinfo.last_sighting); new1 = true; } else if ((self.monsterinfo.aiflags & Defines.AI_PURSUIT_LAST_SEEN) != 0) { self.monsterinfo.aiflags &= ~Defines.AI_PURSUIT_LAST_SEEN; @@ -718,50 +662,42 @@ public class GameAI { } if (marker != null) { - Math3D.VectorCopy(marker.s.origin, - self.monsterinfo.last_sighting); + Math3D.VectorCopy(marker.s.origin, self.monsterinfo.last_sighting); self.monsterinfo.trail_time = marker.timestamp; self.s.angles[Defines.YAW] = self.ideal_yaw = marker.s.angles[Defines.YAW]; - // dprint("heading is "); dprint(ftos(self.ideal_yaw)); + // dprint("heading is "); + // dprint(ftos(self.ideal_yaw)); // dprint("\n"); - - // debug_drawline(self.origin, self.last_sighting, 52); + // debug_drawline(self.origin, self.last_sighting, 52); new1 = true; } } - Math3D.VectorSubtract(self.s.origin, - self.monsterinfo.last_sighting, v); + Math3D.VectorSubtract(self.s.origin, self.monsterinfo.last_sighting, v); d1 = Math3D.VectorLength(v); if (d1 <= dist) { self.monsterinfo.aiflags |= Defines.AI_PURSUE_NEXT; dist = d1; } - Math3D.VectorCopy(self.monsterinfo.last_sighting, - self.goalentity.s.origin); + Math3D.VectorCopy(self.monsterinfo.last_sighting, self.goalentity.s.origin); if (new1) { - // gi.dprintf("checking for course correction\n"); + // gi.dprintf("checking for course correction\n"); tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, self.monsterinfo.last_sighting, self, Defines.MASK_PLAYERSOLID); if (tr.fraction < 1) { - Math3D.VectorSubtract(self.goalentity.s.origin, - self.s.origin, v); + Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); d1 = Math3D.VectorLength(v); center = tr.fraction; d2 = d1 * ((center + 1) / 2); - self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D - .vectoyaw(v); - Math3D - .AngleVectors(self.s.angles, v_forward, v_right, - null); + self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); + Math3D.AngleVectors(self.s.angles, v_forward, v_right, null); Math3D.VectorSet(v, d2, -16, 0); - Math3D.G_ProjectSource(self.s.origin, v, v_forward, - v_right, left_target); + Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); tr = GameBase.gi.trace(self.s.origin, self.mins, self.maxs, left_target, self, Defines.MASK_PLAYERSOLID); left = tr.fraction; @@ -779,42 +715,29 @@ public class GameAI { Math3D.VectorSet(v, d2 * left * 0.5f, -16f, 0f); Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target); - // gi.dprintf("incomplete path, go part way and - // adjust again\n"); + // gi.dprintf("incomplete path, go part way and adjust again\n"); } - Math3D.VectorCopy(self.monsterinfo.last_sighting, - self.monsterinfo.saved_goal); + Math3D.VectorCopy(self.monsterinfo.last_sighting, self.monsterinfo.saved_goal); self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP; - Math3D - .VectorCopy(left_target, - self.goalentity.s.origin); - Math3D.VectorCopy(left_target, - self.monsterinfo.last_sighting); - Math3D.VectorSubtract(self.goalentity.s.origin, - self.s.origin, v); - self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D - .vectoyaw(v); - // gi.dprintf("adjusted left\n"); - // debug_drawline(self.origin, self.last_sighting, 152); + Math3D.VectorCopy(left_target, self.goalentity.s.origin); + Math3D.VectorCopy(left_target, self.monsterinfo.last_sighting); + Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); + self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); + // gi.dprintf("adjusted left\n"); + // debug_drawline(self.origin, self.last_sighting, 152); } else if (right >= center && right > left) { if (right < 1) { Math3D.VectorSet(v, d2 * right * 0.5f, 16f, 0f); Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target); - // gi.dprintf("incomplete path, go part way and - // adjust again\n"); + // gi.dprintf("incomplete path, go part way and adjust again\n"); } - Math3D.VectorCopy(self.monsterinfo.last_sighting, - self.monsterinfo.saved_goal); + Math3D.VectorCopy(self.monsterinfo.last_sighting, self.monsterinfo.saved_goal); self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP; - Math3D.VectorCopy(right_target, - self.goalentity.s.origin); - Math3D.VectorCopy(right_target, - self.monsterinfo.last_sighting); - Math3D.VectorSubtract(self.goalentity.s.origin, - self.s.origin, v); - self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D - .vectoyaw(v); + Math3D.VectorCopy(right_target, self.goalentity.s.origin); + Math3D.VectorCopy(right_target, self.monsterinfo.last_sighting); + Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); + self.s.angles[Defines.YAW] = self.ideal_yaw = Math3D.vectoyaw(v); // gi.dprintf("adjusted right\n"); // debug_drawline(self.origin, self.last_sighting, 152); } diff --git a/src/jake2/game/GameUtil.java b/src/jake2/game/GameUtil.java index 535f1ff..e9c18bf 100644 --- a/src/jake2/game/GameUtil.java +++ b/src/jake2/game/GameUtil.java @@ -20,7 +20,7 @@ // Created on 01.11.2003 by RST. -// $Id: GameUtil.java,v 1.14 2005-11-20 22:18:33 salomo Exp $ +// $Id: GameUtil.java,v 1.15 2005-12-27 21:02:31 salomo Exp $ package jake2.game; @@ -40,8 +40,10 @@ public class GameUtil { } } - /** - * the global "activator" should be set to the entity that initiated the + /** + * Use the targets. + * + * The global "activator" should be set to the entity that initiated the * firing. * * If self.delay is set, a DelayedUse entity will be created that will @@ -58,9 +60,7 @@ public class GameUtil { checkClassname(ent); - // - // check for a delay - // + // check for a delay if (ent.delay != 0) { // create a temp object to fire at a later time t = G_Spawn(); @@ -76,9 +76,8 @@ public class GameUtil { return; } - // - // print the message - // + + // print the message if ((ent.message != null) && (activator.svflags & Defines.SVF_MONSTER) == 0) { GameBase.gi.centerprintf(activator, "" + ent.message); @@ -90,10 +89,7 @@ public class GameUtil { .soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); } - // // kill killtargets - // - EdictIterator edit = null; if (ent.killtarget != null) { @@ -110,7 +106,6 @@ public class GameUtil { } // fire targets - if (ent.target != null) { edit = null; while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, @@ -186,13 +181,11 @@ public class GameUtil { //if ((ed - g_edicts) <= (maxclients.value + BODY_QUEUE_SIZE)) if (ed.index <= (GameBase.maxclients.value + Defines.BODY_QUEUE_SIZE)) { - // gi.dprintf("tried to free special edict\n"); + // gi.dprintf("tried to free special edict\n"); return; } - //memset(ed, 0, sizeof(* ed)); GameBase.g_edicts[ed.index] = new edict_t(ed.index); - //ed.clear(); ed.classname = "freed"; ed.freetime = GameBase.level.time; ed.inuse = false; @@ -208,26 +201,6 @@ public class GameUtil { GameBase.g_edicts[i] = new edict_t(i); } - public static void G_TouchSolids(edict_t ent) { - int i, num; - edict_t touch[] = new edict_t[Defines.MAX_EDICTS], hit; - - num = GameBase.gi.BoxEdicts(ent.absmin, ent.absmax, touch, - Defines.MAX_EDICTS, Defines.AREA_SOLID); - - // be careful, it is possible to have an entity in this - // list removed before we get to it (killtriggered) - for (i = 0; i < num; i++) { - hit = touch[i]; - if (!hit.inuse) - continue; - if (ent.touch != null) { - ent.touch.touch(hit, ent, GameBase.dummyplane, null); - } - if (!ent.inuse) - break; - } - } /** * Kills all entities that would touch the proposed new positioning of ent. @@ -256,6 +229,9 @@ public class GameUtil { return true; // all clear } + /** + * Returns true, if two edicts are on the same team. + */ public static boolean OnSameTeam(edict_t ent1, edict_t ent2) { if (0 == ((int) (GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS))) return false; @@ -265,6 +241,10 @@ public class GameUtil { return false; } + /** + * Returns the team string of an entity + * with respect to rteam_by_model and team_by_skin. + */ static String ClientTeam(edict_t ent) { String value; @@ -296,13 +276,11 @@ public class GameUtil { GameItems.SelectNextItem(ent, -1); } - /* - * ============= range - * - * returns the range catagorization of an entity reletive to self 0 melee + /** + * Returns the range catagorization of an entity reletive to self 0 melee * range, will become hostile even if back is turned 1 visibility and * infront, or visibility and show hostile 2 infront and show hostile 3 only - * triggered by damage ============= + * triggered by damage. */ public static int range(edict_t self, edict_t other) { float[] v = { 0, 0, 0 }; @@ -323,10 +301,8 @@ public class GameUtil { self.monsterinfo.attack_finished = GameBase.level.time + time; } - /* - * ============= infront - * - * returns true if the entity is in front (in sight) of self ============= + /** + * Returns true if the entity is in front (in sight) of self */ public static boolean infront(edict_t self, edict_t other) { float[] vec = { 0, 0, 0 }; @@ -343,11 +319,8 @@ public class GameUtil { return false; } - /* - * ============= visible - * - * returns 1 if the entity is visible to self, even if not infront () - * ============= + /** + * Returns 1 if the entity is visible to self, even if not infront(). */ public static boolean visible(edict_t self, edict_t other) { float[] spot1 = { 0, 0, 0 }; @@ -366,8 +339,8 @@ public class GameUtil { return false; } - /* - * =========== FindTarget + /** + * Finds a target. * * Self is currently not attacking anything, so try to find a target * @@ -379,18 +352,16 @@ public class GameUtil { * * To avoid spending too much time, only a single client (or fakeclient) is * checked each frame. This means multi player games will have slightly - * slower noticing monsters. ============ + * slower noticing monsters. */ static boolean FindTarget(edict_t self) { edict_t client; boolean heardit; int r; - if ((self.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0) - { + if ((self.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0) { if (self.goalentity != null && self.goalentity.inuse - && self.goalentity.classname != null) - { + && self.goalentity.classname != null) { if (self.goalentity.classname.equals("target_actor")) return false; } @@ -523,10 +494,8 @@ public class GameUtil { self.enemy = client; } - - // - // got one - // + + // got one FoundTarget(self); if (0 == (self.monsterinfo.aiflags & Defines.AI_SOUND_TARGET) @@ -614,32 +583,7 @@ public class GameUtil { } }; - /* - * ============= - * range - * - * returns the range catagorization of an entity reletive to self. 0 melee - * range, will become hostile even if back is turned 1 visibility and - * infront, or visibility and show hostile 2 infront and show hostile 3 only - * triggered by damage - * - */ - // static int range(edict_t self, edict_t other) - // { - // float[] v= { 0, 0, 0 }; - // float len; - // - // VectorSubtract(self.s.origin, other.s.origin, v); - // len= VectorLength(v); - // if (len < MELEE_DISTANCE) - // return RANGE_MELEE; - // if (len < 500) - // return RANGE_NEAR; - // if (len < 1000) - // return RANGE_MID; - // return RANGE_FAR; - // } - // ============================================================================ + public static EntThinkAdapter M_CheckAttack = new EntThinkAdapter() { public String getID() { return "M_CheckAttack"; } @@ -680,7 +624,7 @@ public class GameUtil { return true; } - // missile attack + // missile attack if (self.monsterinfo.attack == null) return false; diff --git a/src/jake2/game/Info.java b/src/jake2/game/Info.java index 7bb7c99..316e43c 100644 --- a/src/jake2/game/Info.java +++ b/src/jake2/game/Info.java @@ -19,7 +19,9 @@ */ // Created on 27.12.2003 by RST. -// $Id: Info.java,v 1.5 2004-10-21 03:32:53 cawe Exp $ + +// $Id: Info.java,v 1.6 2005-12-27 21:02:31 salomo Exp $ + package jake2.game; import jake2.Defines; @@ -29,6 +31,9 @@ import java.util.StringTokenizer; public class Info { + /** + * Returns a value for a key from an info string. + */ public static String Info_ValueForKey(String s, String key) { StringTokenizer tk = new StringTokenizer(s, "\\"); @@ -50,10 +55,9 @@ public class Info { } /** - * TODO RST: DANGEROUS port, returns the modified userinfo string, was - * pointer-pointer manipulation first + * Sets a value for a key in the user info string. */ - public static String Info_SetValueForKey1(String s, String key, String value) { + public static String Info_SetValueForKey(String s, String key, String value) { if (value == null || value.length() == 0) return s; @@ -79,7 +83,7 @@ public class Info { return s; } - StringBuffer sb = new StringBuffer(Info_RemoveKey1(s, key)); + StringBuffer sb = new StringBuffer(Info_RemoveKey(s, key)); if (sb.length() + 2 + key.length() + value.length() > Defines.MAX_INFO_STRING) { @@ -92,8 +96,10 @@ public class Info { return sb.toString(); } - /** TODO RST: DANGEROUS port, returns now the modified userinfo string. */ - public static String Info_RemoveKey1(String s, String key) { + /** + * Removes a key and value from an info string. + */ + public static String Info_RemoveKey(String s, String key) { StringBuffer sb = new StringBuffer(512); @@ -119,35 +125,14 @@ public class Info { return sb.toString(); - //some old code follows - - /* - * char * start; char pkey[512]; char value[512]; char * o; - * - * if (key.indexOf('\\')!=-1) { Com.Printf ("Can't use a key with a - * \\\n"); return s; } - * - * while () { start = s; if (* s == '\\') s++; o = pkey; while (* s != - * '\\') { if (!* s) return; o++ = * s++; } o = 0; s++; - * - * o = value; while (* s != '\\' && * s) { if (!* s) return; o++ = * - * s++; } o = 0; - * - * if (!strcmp(key, pkey)) { strcpy(start, s); // remove this part - * return; } - * - * if (!* s) return; } - */ } - /* - * ================== Info_Validate - * + /** * Some characters are illegal in info strings because they can mess up the - * server's parsing ================== + * server's parsing. */ public static boolean Info_Validate(String s) { - return !((s.indexOf('"') != -1) || (s.indexOf(';') != -1)); + return !((s.indexOf('"') != -1) || (s.indexOf(';') != -1) || (s.indexOf('\\') != -1)); } private static String fillspaces = " "; @@ -175,33 +160,8 @@ public class Info { if (len < 20) { sb.append(fillspaces.substring(len)); } - sb.append('=').append(value1).append('\n'); } - Com.Printf(sb.toString()); - - /* - * some old code follows - * - * char * o; int l; - * - * if (* s == '\\') s++; while (* s) { o = key; while (* s && * s != - * '\\') o++ = * s++; - * - * l = o - key; if (l < 20) { memset(o, ' ', 20 - l); key[20] = 0; } - * else o = 0; Com_Printf("%s", key); - * - * if (!* s) { Com_Printf("MISSING VALUE\n"); return; } - * - * o = value; s++; while (* s && * s != '\\') o++ = * s++; o = 0; - * - * if (* s) s++; Com_Printf("%s\n", value); } - */ - } - - public static void testintern(StringBuffer in) { - in.setLength(0); - in.append("123!"); } }
\ No newline at end of file diff --git a/src/jake2/game/PlayerClient.java b/src/jake2/game/PlayerClient.java index b14f691..ff6415d 100644 --- a/src/jake2/game/PlayerClient.java +++ b/src/jake2/game/PlayerClient.java @@ -20,7 +20,7 @@ // Created on 28.12.2003 by RST. -// $Id: PlayerClient.java,v 1.11 2005-11-20 22:18:33 salomo Exp $ +// $Id: PlayerClient.java,v 1.12 2005-12-27 21:02:30 salomo Exp $ package jake2.game; @@ -33,10 +33,9 @@ import jake2.util.Math3D; public class PlayerClient { public static int player_die_i = 0; - /* - * ================== - * player_die - * ================== + + /** + * player_die. */ static EntDieAdapter player_die = new EntDieAdapter() { public String getID() { return "player_die"; } @@ -59,7 +58,7 @@ public class PlayerClient { self.maxs[2] = -8; - // self.solid = SOLID_NOT; + // self.solid = SOLID_NOT; self.svflags |= Defines.SVF_DEADMONSTER; if (self.deadflag == 0) { @@ -161,7 +160,7 @@ public class PlayerClient { if (Math3D.VectorLength(d) < 384) { if ((self.targetname == null) || Lib.Q_stricmp(self.targetname, spot.targetname) != 0) { - // gi.dprintf("FixCoopSpots changed %s at %s targetname + // gi.dprintf("FixCoopSpots changed %s at %s targetname // from %s to %s\n", self.classname, // vtos(self.s.origin), self.targetname, // spot.targetname); @@ -220,13 +219,10 @@ public class PlayerClient { int n; if (self.health < -40) { - GameBase.gi - .sound(self, Defines.CHAN_BODY, GameBase.gi - .soundindex("misc/udeath.wav"), 1, - Defines.ATTN_NORM, 0); + GameBase.gi.sound(self, Defines.CHAN_BODY, + GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0); for (n = 0; n < 4; n++) - GameMisc.ThrowGib(self, - "models/objects/gibs/sm_meat/tris.md2", damage, + GameMisc.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC); self.s.origin[2] -= 48; GameMisc.ThrowClientHead(self, damage); @@ -250,7 +246,7 @@ public class PlayerClient { }; - /* + /** * QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32) The normal * starting point for a level. */ @@ -264,9 +260,9 @@ public class PlayerClient { } } - /* + /** * QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 32) potential - * spawning position for deathmatch games + * spawning position for deathmatch games. */ public static void SP_info_player_deathmatch(edict_t self) { if (0 == GameBase.deathmatch.value) { @@ -276,9 +272,9 @@ public class PlayerClient { GameMisc.SP_misc_teleporter_dest.think(self); } - /* + /** * QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 32) potential - * spawning position for coop games + * spawning position for coop games. */ public static void SP_info_player_coop(edict_t self) { @@ -307,7 +303,7 @@ public class PlayerClient { } } - /* + /** * QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32) The * deathmatch intermission point will be at one of these Use 'angles' * instead of 'angle', so you can set pitch or roll as well as yaw. 'pitch @@ -508,14 +504,9 @@ public class PlayerClient { self.client.resp.score--; } - //======================================================================= - /* - * ============== - * InitClientPersistant - * + /** * This is only called when the game first initializes in single player, but - * is called after each death and level change in deathmatch - * ============== + * is called after each death and level change in deathmatch. */ public static void InitClientPersistant(gclient_t client) { gitem_t item; @@ -554,14 +545,10 @@ public class PlayerClient { client.resp.coop_respawn.set(client.pers); } - /* - * ================== - * SaveClientData - * + /** * Some information that should be persistant, like health, is still stored * in the edict structure, so it needs to be mirrored out to the client * structure before all the edicts are wiped. - * ================== */ public static void SaveClientData() { int i; @@ -590,12 +577,8 @@ public class PlayerClient { ent.client.resp.score = ent.client.pers.score; } - /* - * ================ - * PlayersRangeFromSpot - * - * Returns the distance to the nearest player from the given spot - * ================ + /** + * Returns the distance to the nearest player from the given spot. */ static float PlayersRangeFromSpot(edict_t spot) { edict_t player; @@ -625,12 +608,8 @@ public class PlayerClient { return bestplayerdistance; } - /* - * ================ - * SelectRandomDeathmatchSpawnPoint - * - * go to a random point, but NOT the two points closest to other players - * ================ + /** + * Go to a random point, but NOT the two points closest to other players. */ public static edict_t SelectRandomDeathmatchSpawnPoint() { edict_t spot, spot1, spot2; @@ -685,11 +664,8 @@ public class PlayerClient { return spot; } - /* - * ================ - * SelectFarthestDeathmatchSpawnPoint - * - * ================ + /** + * If turned on in the dmflags, select a spawn point far away from other players. */ static edict_t SelectFarthestDeathmatchSpawnPoint() { edict_t bestspot; @@ -702,7 +678,7 @@ public class PlayerClient { EdictIterator es = null; while ((es = GameBase.G_Find(es, GameBase.findByClass, - "info_player_deathmatch")).o != null) { + "info_player_deathmatch")) != null) { spot = es.o; bestplayerdistance = PlayersRangeFromSpot(spot); @@ -726,6 +702,7 @@ public class PlayerClient { return edit.o; } + public static edict_t SelectDeathmatchSpawnPoint() { if (0 != ((int) (GameBase.dmflags.value) & Defines.DF_SPAWN_FARTHEST)) return SelectFarthestDeathmatchSpawnPoint(); @@ -754,7 +731,6 @@ public class PlayerClient { es = GameBase.G_Find(es, GameBase.findByClass, "info_player_coop"); - // nullpointer exi fixed (RST). if (es == null) return null; @@ -776,12 +752,8 @@ public class PlayerClient { } - /* - * =========== - * SelectSpawnPoint - * - * Chooses a player start, deathmatch start, coop start, etc - * ============ + /** + * Chooses a player start, deathmatch start, coop start, etc. */ public static void SelectSpawnPoint(edict_t ent, float[] origin, float[] angles) { @@ -835,7 +807,6 @@ public class PlayerClient { Math3D.VectorCopy(spot.s.angles, angles); } - //====================================================================== public static void InitBodyQue() { int i; @@ -913,8 +884,8 @@ public class PlayerClient { return true; } - /* - * only called when pers.spectator changes note that resp.spectator should + /** + * Only called when pers.spectator changes note that resp.spectator should * be the opposite of pers.spectator here */ public static void spectator_respawn(edict_t ent) { @@ -1000,13 +971,8 @@ public class PlayerClient { + " joined the game\n"); } - //============================================================== - - /* - * =========== PutClientInServer - * + /** * Called when a player connects to a server or respawns in a deathmatch. - * ============ */ public static void PutClientInServer(edict_t ent) { float[] mins = { -16, -16, -24 }; @@ -1160,13 +1126,9 @@ public class PlayerClient { PlayerWeapon.ChangeWeapon(ent); } - /* - * ===================== - * ClientBeginDeathmatch - * + /** * A client has just connected to the server in deathmatch mode, so clear * everything out before starting them. - * ===================== */ public static void ClientBeginDeathmatch(edict_t ent) { GameUtil.G_InitEdict(ent, ent.index); @@ -1194,13 +1156,9 @@ public class PlayerClient { PlayerView.ClientEndServerFrame(ent); } - /* - * =========== - * ClientBegin - * - * called when a client has finished connecting, and is ready to be placed + /** + * Called when a client has finished connecting, and is ready to be placed * into the game. This will happen every level load. - * ============ */ public static void ClientBegin(edict_t ent) { int i; @@ -1252,15 +1210,12 @@ public class PlayerClient { PlayerView.ClientEndServerFrame(ent); } - /* - * =========== - * ClientUserInfoChanged - * - * called whenever the player updates a userinfo variable. + /** + * Called whenever the player updates a userinfo variable. * * The game can override any of the settings in place (forcing skins or * names, etc) before copying it off. - * ============ + * */ public static String ClientUserinfoChanged(edict_t ent, String userinfo) { String s; @@ -1318,16 +1273,12 @@ public class PlayerClient { return userinfo; } - /* - * =========== - * ClientConnect - * + /** * Called when a player begins connecting to the server. The game can refuse * entrance to a client by returning false. If the client is allowed, the * connection process will continue and eventually get to ClientBegin() * Changing levels will NOT cause this to be called again, but loadgames * will. - * ============ */ public static boolean ClientConnect(edict_t ent, String userinfo) { String value; @@ -1335,7 +1286,7 @@ public class PlayerClient { // check to see if they are on the banned IP list value = Info.Info_ValueForKey(userinfo, "ip"); if (GameSVCmds.SV_FilterPacket(value)) { - userinfo = Info.Info_SetValueForKey1(userinfo, "rejmsg", "Banned."); + userinfo = Info.Info_SetValueForKey(userinfo, "rejmsg", "Banned."); return false; } @@ -1346,7 +1297,7 @@ public class PlayerClient { int i, numspec; if (!passwdOK(GameBase.spectator_password.string, value)) { - userinfo = Info.Info_SetValueForKey1(userinfo, "rejmsg", + userinfo = Info.Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect."); return false; } @@ -1358,7 +1309,7 @@ public class PlayerClient { numspec++; if (numspec >= GameBase.maxspectators.value) { - userinfo = Info.Info_SetValueForKey1(userinfo, "rejmsg", + userinfo = Info.Info_SetValueForKey(userinfo, "rejmsg", "Server spectator limit is full."); return false; } @@ -1366,7 +1317,7 @@ public class PlayerClient { // check for a password value = Info.Info_ValueForKey(userinfo, "password"); if (!passwdOK(GameBase.spectator_password.string, value)) { - userinfo = Info.Info_SetValueForKey1(userinfo, "rejmsg", + userinfo = Info.Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect."); return false; } @@ -1394,13 +1345,8 @@ public class PlayerClient { return true; } - /* - * =========== - * ClientDisconnect - * - * Called when a player drops from the server. Will not be called between - * levels. - * ============ + /** + * Called when a player drops from the server. Will not be called between levels. */ public static void ClientDisconnect(edict_t ent) { int playernum; @@ -1429,22 +1375,28 @@ public class PlayerClient { } /* - * static int CheckBlock(, int c) { int v, i; v = 0; for (i = 0; i < c; i++) - * v += ((byte *) b)[i]; return v; } + * static int CheckBlock(int c) + * { + * int v, i; + * v = 0; + * for (i = 0; i < c; i++) + * v += ((byte *) b)[i]; + * return v; + * } * - * public static void PrintPmove(pmove_t * pm) { unsigned c1, c2; + * public static void PrintPmove(pmove_t * pm) + * { + * unsigned c1, c2; * - * c1 = CheckBlock(& pm.s, sizeof(pm.s)); c2 = CheckBlock(& pm.cmd, - * sizeof(pm.cmd)); Com_Printf("sv %3i:%i %i\n", pm.cmd.impulse, c1, c2); } + * c1 = CheckBlock(&pm.s, sizeof(pm.s)); + * c2 = CheckBlock(&pm.cmd, sizeof(pm.cmd)); + * Com_Printf("sv %3i:%i %i\n", pm.cmd.impulse, c1, c2); + * } */ - /* - * ============== - * ClientThink - * + /** * This will be called once for each client frame, which will usually be a - * couple times for each server frame. - * ============== + * couple times for each server frame. */ public static void ClientThink(edict_t ent, usercmd_t ucmd) { gclient_t client; @@ -1475,7 +1427,6 @@ public class PlayerClient { } else { // set up for pmove - //memset(& pm, 0, sizeof(pm)); pm = new pmove_t(); if (ent.movetype == Defines.MOVETYPE_NOCLIP) @@ -1497,7 +1448,7 @@ public class PlayerClient { if (client.old_pmove.equals(pm.s)) { pm.snapinitial = true; - // gi.dprintf ("pmove changed!\n"); + // gi.dprintf ("pmove changed!\n"); } // this should be a copy @@ -1615,13 +1566,9 @@ public class PlayerClient { } } - /* - * ============== - * ClientBeginServerFrame - * + /** * This will be called once for each server frame, before running any other * entities in the world. - * ============== */ public static void ClientBeginServerFrame(edict_t ent) { gclient_t client; @@ -1671,7 +1618,9 @@ public class PlayerClient { client.latched_buttons = 0; } - /** Returns true, if the players gender flag was set to female . */ + /** + * Returns true, if the players gender flag was set to female. + */ public static boolean IsFemale(edict_t ent) { char info; @@ -1703,10 +1652,8 @@ public class PlayerClient { return false; } - /* - * ================== - * LookAtKiller - * ================== + /** + * Changes the camera view to look at the killer. */ public static void LookAtKiller(edict_t self, edict_t inflictor, edict_t attacker) { @@ -1737,7 +1684,11 @@ public class PlayerClient { self.client.killer_yaw += 360; } - + + + /** + * Drop items and weapons in deathmatch games. + */ public static void TossClientWeapon(edict_t self) { gitem_t item; edict_t drop; diff --git a/src/jake2/game/PlayerView.java b/src/jake2/game/PlayerView.java index c7ebef3..862495f 100644 --- a/src/jake2/game/PlayerView.java +++ b/src/jake2/game/PlayerView.java @@ -19,7 +19,7 @@ */ // Created on 28.12.2003 by RST. -// $Id: PlayerView.java,v 1.4 2005-11-16 22:24:52 salomo Exp $ +// $Id: PlayerView.java,v 1.5 2005-12-27 21:02:30 salomo Exp $ package jake2.game; import jake2.Defines; @@ -40,11 +40,8 @@ public class PlayerView { public static float[] up = { 0, 0, 0 }; - /* - * =============== - * SV_CalcRoll - * - * =============== + /** + * SV_CalcRoll. */ public static float SV_CalcRoll(float[] angles, float[] velocity) { float sign; @@ -212,18 +209,14 @@ public class PlayerView { client.damage_knockback = 0; } - /* - * =============== - * SV_CalcViewOffset - * - * Auto pitching on slopes? - * - * fall from 128: 400 = 160000 fall from 256: 580 = 336400 fall from 384: - * 720 = 518400 fall from 512: 800 = 640000 fall from 640: 960 = + /** * + * fall from 128: 400 = 160000 + * fall from 256: 580 = 336400 + * fall from 384: 720 = 518400 + * fall from 512: 800 = 640000 + * fall from 640: 960 = * damage = deltavelocity*deltavelocity * 0.0001 - * - * =============== */ public static void SV_CalcViewOffset(edict_t ent) { float angles[] = { 0, 0, 0 }; @@ -232,8 +225,6 @@ public class PlayerView { float delta; float[] v = { 0, 0, 0 }; - //=================================== - // base angles angles = ent.client.ps.kick_angles; @@ -245,12 +236,11 @@ public class PlayerView { ent.client.ps.viewangles[Defines.PITCH] = -15; ent.client.ps.viewangles[Defines.YAW] = ent.client.killer_yaw; } else { + // add angles based on weapon kick - Math3D.VectorCopy(ent.client.kick_angles, angles); // add angles based on damage kick - ratio = (ent.client.v_dmg_time - GameBase.level.time) / Defines.DAMAGE_TIME; if (ratio < 0) { @@ -262,7 +252,6 @@ public class PlayerView { angles[Defines.ROLL] += ratio * ent.client.v_dmg_roll; // add pitch based on fall kick - ratio = (ent.client.fall_time - GameBase.level.time) / Defines.FALL_TIME; if (ratio < 0) @@ -270,7 +259,6 @@ public class PlayerView { angles[Defines.PITCH] += ratio * ent.client.fall_value; // add angles based on velocity - delta = Math3D.DotProduct(ent.velocity, forward); angles[Defines.PITCH] += delta * GameBase.run_pitch.value; @@ -278,7 +266,6 @@ public class PlayerView { angles[Defines.ROLL] += delta * GameBase.run_roll.value; // add angles based on bob - delta = bobfracsin * GameBase.bob_pitch.value * xyspeed; if ((ent.client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0) delta *= 6; // crouching @@ -291,18 +278,13 @@ public class PlayerView { angles[Defines.ROLL] += delta; } - //=================================== - // base origin - Math3D.VectorClear(v); // add view height - v[2] += ent.viewheight; // add fall height - ratio = (ent.client.fall_time - GameBase.level.time) / Defines.FALL_TIME; if (ratio < 0) @@ -310,10 +292,10 @@ public class PlayerView { v[2] -= ratio * ent.client.fall_value * 0.4; // add bob height - bob = bobfracsin * xyspeed * GameBase.bob_up.value; if (bob > 6) bob = 6; + //gi.DebugGraph (bob *2, 255); v[2] += bob; @@ -340,10 +322,8 @@ public class PlayerView { Math3D.VectorCopy(v, ent.client.ps.viewoffset); } - /* - * ============== - * SV_CalcGunOffset - * ============== + /** + * Calculates where to draw the gun. */ public static void SV_CalcGunOffset(edict_t ent) { int i; @@ -387,10 +367,8 @@ public class PlayerView { } } - /* - * ============= - * SV_AddBlend - * ============= + /** + * Adds a blending effect to the clients view. */ public static void SV_AddBlend(float r, float g, float b, float a, float v_blend[]) { @@ -407,10 +385,8 @@ public class PlayerView { v_blend[3] = a2; } - /* - * ============= - * SV_CalcBlend - * ============= + /** + * Calculates the blending color according to the players environment. */ public static void SV_CalcBlend(edict_t ent) { int contents; @@ -438,27 +414,23 @@ public class PlayerView { if (ent.client.quad_framenum > GameBase.level.framenum) { remaining = (int) (ent.client.quad_framenum - GameBase.level.framenum); if (remaining == 30) // beginning to fade - GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi - .soundindex("items/damage2.wav"), 1, Defines.ATTN_NORM, - 0); + GameBase.gi.sound(ent, Defines.CHAN_ITEM, + GameBase.gi.soundindex("items/damage2.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 0, 1, 0.08f, ent.client.ps.blend); } else if (ent.client.invincible_framenum > GameBase.level.framenum) { - remaining = (int) ent.client.invincible_framenum - - GameBase.level.framenum; + remaining = (int) ent.client.invincible_framenum - GameBase.level.framenum; if (remaining == 30) // beginning to fade - GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi - .soundindex("items/protect2.wav"), 1, - Defines.ATTN_NORM, 0); + GameBase.gi.sound(ent, Defines.CHAN_ITEM, + GameBase.gi.soundindex("items/protect2.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(1, 1, 0, 0.08f, ent.client.ps.blend); } else if (ent.client.enviro_framenum > GameBase.level.framenum) { remaining = (int) ent.client.enviro_framenum - GameBase.level.framenum; if (remaining == 30) // beginning to fade - GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi - .soundindex("items/airout.wav"), 1, Defines.ATTN_NORM, - 0); + GameBase.gi.sound(ent, Defines.CHAN_ITEM, + GameBase.gi.soundindex("items/airout.wav"), 1, Defines.ATTN_NORM, 0); if (remaining > 30 || (remaining & 4) != 0) SV_AddBlend(0, 1, 0, 0.08f, ent.client.ps.blend); } else if (ent.client.breather_framenum > GameBase.level.framenum) { @@ -493,10 +465,8 @@ public class PlayerView { ent.client.bonus_alpha = 0; } - /* - * ================= - * P_FallingDamage - * ================= + /** + * Calculates damage and effect when a player falls down. */ public static void P_FallingDamage(edict_t ent) { float delta; @@ -566,10 +536,8 @@ public class PlayerView { } } - /* - * ============= - * P_WorldEffects - * ============= + /** + * General effect handling for a player. */ public static void P_WorldEffects() { boolean breather; @@ -950,13 +918,10 @@ public class PlayerView { } } - /* - * ================= - * ClientEndServerFrame - * + + /** * Called for each player at the end of the server frame and right after - * spawning - * ================= + * spawning. */ public static void ClientEndServerFrame(edict_t ent) { float bobtime; diff --git a/src/jake2/qcommon/Cvar.java b/src/jake2/qcommon/Cvar.java index c0aa6ab..eaeba52 100644 --- a/src/jake2/qcommon/Cvar.java +++ b/src/jake2/qcommon/Cvar.java @@ -2,7 +2,7 @@ * Cvar.java * Copyright (C) 2003 * - * $Id: Cvar.java,v 1.8 2005-05-26 16:56:32 hzi Exp $ + * $Id: Cvar.java,v 1.9 2005-12-27 21:02:30 salomo Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -114,8 +114,8 @@ public class Cvar extends Globals { return null; } - /* - * ============ Cvar_FullSet ============ + /** + * Creates a variable if not found and sets their value, the parsed float value and their flags. */ public static cvar_t FullSet(String var_name, String value, int flags) { cvar_t var; @@ -142,20 +142,29 @@ public class Cvar extends Globals { return var; } - /* - * ============ Cvar_Set ============ + /** + * Sets the value of the variable without forcing. */ public static cvar_t Set(String var_name, String value) { return Set2(var_name, value, false); } - /* - * ============ Cvar_Set2 ============ + /** + * Sets the value of the variable with forcing. + */ + public static cvar_t ForceSet(String var_name, String value) { + return Cvar.Set2(var_name, value, true); + } + + /** + * Gereric set function, sets the value of the variable, with forcing its even possible to + * override the variables write protection. */ static cvar_t Set2(String var_name, String value, boolean force) { cvar_t var = Cvar.FindVar(var_name); - if (var == null) { // create it + if (var == null) { + // create it return Cvar.Get(var_name, value, 0); } @@ -176,7 +185,6 @@ public class Cvar extends Globals { if (var.latched_string != null) { if (value.equals(var.latched_string)) return var; - //Z_Free (var.latched_string); var.latched_string = null; } else { if (value.equals(var.string)) @@ -202,7 +210,6 @@ public class Cvar extends Globals { } } else { if (var.latched_string != null) { - //Z_Free(var.latched_string); var.latched_string = null; } } @@ -225,6 +232,10 @@ public class Cvar extends Globals { return var; } + /** + * Set command, sets variables. + */ + static xcommand_t Set_f = new xcommand_t() { public void execute() { int c; @@ -253,6 +264,9 @@ public class Cvar extends Globals { }; + /** + * List command, lists all available commands. + */ static xcommand_t List_f = new xcommand_t() { public void execute() { cvar_t var; @@ -284,19 +298,14 @@ public class Cvar extends Globals { } }; - /* - * ============ Cvar_ForceSet ============ - */ - public static cvar_t ForceSet(String var_name, String value) { - return Cvar.Set2(var_name, value, true); - } - /* - * ============ Cvar_SetValue ============ + + /** + * Sets a float value of a variable. + * + * The overloading is very important, there was a problem with + * networt "rate" string --> 10000 became "10000.0" and that wasn't right. */ - // the overloading is very important - // there was a problem with networt "rate" string - // 10000 became "10000.0" and that wasn't right public static void SetValue(String var_name, int value) { Cvar.Set(var_name, "" + value); } @@ -309,8 +318,8 @@ public class Cvar extends Globals { } } - /* - * ============ Cvar_VariableValue ============ + /** + * Returns the float value of a variable. */ public static float VariableValue(String var_name) { cvar_t var = Cvar.FindVar(var_name); @@ -324,10 +333,8 @@ public class Cvar extends Globals { return val; } - /* - * ============ Cvar_Command - * - * Handles variable inspection and changing from the console ============ + /** + * Handles variable inspection and changing from the console. */ public static boolean Command() { cvar_t v; @@ -355,16 +362,22 @@ public class Cvar extends Globals { for (var = Globals.cvar_vars; var != null; var = var.next) { if ((var.flags & bit) != 0) - info = Info.Info_SetValueForKey1(info, var.name, var.string); + info = Info.Info_SetValueForKey(info, var.name, var.string); } return info; } - // returns an info string containing all the CVAR_SERVERINFO cvars + /** + * Returns an info string containing all the CVAR_SERVERINFO cvars. + */ public static String Serverinfo() { return BitInfo(Defines.CVAR_SERVERINFO); } + + /** + * Any variables with latched values will be updated. + */ public static void GetLatchedVars() { cvar_t var; @@ -386,11 +399,16 @@ public class Cvar extends Globals { } /** - * returns an info string containing all the CVAR_USERINFO cvars. + * Returns an info string containing all the CVAR_USERINFO cvars. */ public static String Userinfo() { return BitInfo(CVAR_USERINFO); } + + /** + * Appends lines containing \"set vaqriable value\" for all variables + * with the archive flag set true. + */ public static void WriteVariables(String path) { cvar_t var; @@ -419,8 +437,8 @@ public class Cvar extends Globals { Lib.fclose(f); } - /* - * ============ Cvar_CompleteVariable ============ + /** + * Variable typing auto completition. */ public static Vector CompleteVariable(String partial) { @@ -434,8 +452,8 @@ public class Cvar extends Globals { return vars; } - /* - * ============ Cvar_InfoValidate ============ + /** + * Some characters are invalid for info strings. */ static boolean InfoValidate(String s) { if (s.indexOf("\\") != -1) diff --git a/src/jake2/qcommon/PMove.java b/src/jake2/qcommon/PMove.java index 3a35523..4330a23 100644 --- a/src/jake2/qcommon/PMove.java +++ b/src/jake2/qcommon/PMove.java @@ -19,7 +19,7 @@ */ // Created on 25.01.2004 by RST. -// $Id: PMove.java,v 1.6 2005-01-12 12:14:16 hzi Exp $ +// $Id: PMove.java,v 1.7 2005-12-27 21:02:30 salomo Exp $ package jake2.qcommon; import jake2.Defines; @@ -54,7 +54,7 @@ public class PMove { public static pmove_t pm; - public static PMove.pml_t pml = new PMove.pml_t(); + public static pml_t pml = new pml_t(); // movement parameters public static float pm_stopspeed = 100; @@ -75,38 +75,16 @@ public class PMove { public static float pm_waterspeed = 400; - /* - * ================ PM_SnapPosition - * - * On exit, the origin will have a value that is pre-quantized to the 0.125 - * precision of the network channel and in a valid position. - * ================ - */ // try all single bits first public static int jitterbits[] = { 0, 4, 1, 2, 3, 5, 6, 7 }; - /* - * ================ PM_InitialSnapPosition - * - * ================ - */ public static int offset[] = { 0, -1, 1 }; - /* - * - * walking up a step should kill some velocity - * - */ - /* - * ================== PM_ClipVelocity - * - * Slide off of the impacting object returns the blocked flags (1 = floor, 2 = - * step / wall) ================== + /** + * Slide off of the impacting object returns the blocked flags (1 = floor, 2 = step / wall) */ - - public static void PM_ClipVelocity(float[] in, float[] normal, float[] out, - float overbounce) { + public static void PM_ClipVelocity(float[] in, float[] normal, float[] out, float overbounce) { float backoff; float change; int i; @@ -122,12 +100,14 @@ public class PMove { } } + static float[] planes[] = new float[GameBase.MAX_CLIP_PLANES][3]; + public static void PM_StepSlideMove_() { int bumpcount, numbumps; float[] dir = { 0, 0, 0 }; float d; int numplanes; - float[] planes[] = new float[GameBase.MAX_CLIP_PLANES][3]; + float[] primal_velocity = { 0, 0, 0 }; int i, j; trace_t trace; @@ -136,26 +116,26 @@ public class PMove { numbumps = 4; - Math3D.VectorCopy(PMove.pml.velocity, primal_velocity); + Math3D.VectorCopy(pml.velocity, primal_velocity); numplanes = 0; - time_left = PMove.pml.frametime; + time_left = pml.frametime; for (bumpcount = 0; bumpcount < numbumps; bumpcount++) { for (i = 0; i < 3; i++) - end[i] = PMove.pml.origin[i] + time_left - * PMove.pml.velocity[i]; + end[i] = pml.origin[i] + time_left + * pml.velocity[i]; - trace = PMove.pm.trace.trace(PMove.pml.origin, PMove.pm.mins, - PMove.pm.maxs, end); + trace = pm.trace.trace(pml.origin, pm.mins, + pm.maxs, end); if (trace.allsolid) { // entity is trapped in another solid - PMove.pml.velocity[2] = 0; // don't build up falling damage + pml.velocity[2] = 0; // don't build up falling damage return; } if (trace.fraction > 0) { // actually covered some distance - Math3D.VectorCopy(trace.endpos, PMove.pml.origin); + Math3D.VectorCopy(trace.endpos, pml.origin); numplanes = 0; } @@ -163,76 +143,70 @@ public class PMove { break; // moved the entire distance // save entity for contact - if (PMove.pm.numtouch < Defines.MAXTOUCH && trace.ent != null) { - //rst: just for debugging touches. - //if (trace.ent.index != -1 && trace.ent.index != 0) - //Com.p("touch: " + trace.ent.classname + " (" + - // trace.ent.index + ")" ); - - PMove.pm.touchents[PMove.pm.numtouch] = trace.ent; - PMove.pm.numtouch++; + if (pm.numtouch < Defines.MAXTOUCH && trace.ent != null) { + pm.touchents[pm.numtouch] = trace.ent; + pm.numtouch++; } time_left -= time_left * trace.fraction; // slide along this plane - if (numplanes >= GameBase.MAX_CLIP_PLANES) { // this shouldn't - // really happen - Math3D.VectorCopy(Globals.vec3_origin, PMove.pml.velocity); + if (numplanes >= GameBase.MAX_CLIP_PLANES) { + // this shouldn't really happen + Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); break; } 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++) { - PMove.PM_ClipVelocity(PMove.pml.velocity, planes[i], - PMove.pml.velocity, 1.01f); + PM_ClipVelocity(pml.velocity, planes[i], + pml.velocity, 1.01f); for (j = 0; j < numplanes; j++) if (j != i) { - if (Math3D.DotProduct(PMove.pml.velocity, planes[j]) < 0) + if (Math3D.DotProduct(pml.velocity, planes[j]) < 0) break; // not ok } if (j == numplanes) break; } - if (i != numplanes) { // go along this plane - } else { // go along the crease + if (i != numplanes) { + // go along this plane + } else { + // go along the crease if (numplanes != 2) { - // Con_Printf ("clip velocity, numplanes == - // %i\n",numplanes); - Math3D.VectorCopy(Globals.vec3_origin, PMove.pml.velocity); + // Com.printf("clip velocity, numplanes == " + numplanes + "\n"); + Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); break; } Math3D.CrossProduct(planes[0], planes[1], dir); - d = Math3D.DotProduct(dir, PMove.pml.velocity); - Math3D.VectorScale(dir, d, PMove.pml.velocity); + d = Math3D.DotProduct(dir, pml.velocity); + Math3D.VectorScale(dir, d, pml.velocity); } - // + // if velocity is against the original velocity, stop dead // to avoid tiny occilations in sloping corners - // - if (Math3D.DotProduct(PMove.pml.velocity, primal_velocity) <= 0) { - Math3D.VectorCopy(Globals.vec3_origin, PMove.pml.velocity); + if (Math3D.DotProduct(pml.velocity, primal_velocity) <= 0) { + Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); break; } } - if (PMove.pm.s.pm_time != 0) { - Math3D.VectorCopy(primal_velocity, PMove.pml.velocity); + if (pm.s.pm_time != 0) { + Math3D.VectorCopy(primal_velocity, pml.velocity); } } - /* - * ================== PM_StepSlideMove + /** + * Each intersection will try to step over the obstruction instead of + * sliding along it. * - * ================== + * Returns a new origin, velocity, and contact entity. + * Does not modify any world state? */ public static void PM_StepSlideMove() { float[] start_o = { 0, 0, 0 }, start_v = { 0, 0, 0 }; @@ -242,37 +216,37 @@ public class PMove { // float [] delta; float[] up = { 0, 0, 0 }, down = { 0, 0, 0 }; - Math3D.VectorCopy(PMove.pml.origin, start_o); - Math3D.VectorCopy(PMove.pml.velocity, start_v); + Math3D.VectorCopy(pml.origin, start_o); + Math3D.VectorCopy(pml.velocity, start_v); PM_StepSlideMove_(); - Math3D.VectorCopy(PMove.pml.origin, down_o); - Math3D.VectorCopy(PMove.pml.velocity, down_v); + Math3D.VectorCopy(pml.origin, down_o); + Math3D.VectorCopy(pml.velocity, down_v); Math3D.VectorCopy(start_o, up); up[2] += Defines.STEPSIZE; - trace = PMove.pm.trace.trace(up, PMove.pm.mins, PMove.pm.maxs, up); + trace = pm.trace.trace(up, pm.mins, pm.maxs, up); if (trace.allsolid) return; // can't step up // try sliding above - Math3D.VectorCopy(up, PMove.pml.origin); - Math3D.VectorCopy(start_v, PMove.pml.velocity); + Math3D.VectorCopy(up, pml.origin); + Math3D.VectorCopy(start_v, pml.velocity); PM_StepSlideMove_(); // push down the final amount - Math3D.VectorCopy(PMove.pml.origin, down); + Math3D.VectorCopy(pml.origin, down); down[2] -= Defines.STEPSIZE; - trace = PMove.pm.trace.trace(PMove.pml.origin, PMove.pm.mins, - PMove.pm.maxs, down); + trace = pm.trace.trace(pml.origin, pm.mins, + pm.maxs, down); if (!trace.allsolid) { - Math3D.VectorCopy(trace.endpos, PMove.pml.origin); + Math3D.VectorCopy(trace.endpos, pml.origin); } - Math3D.VectorCopy(PMove.pml.origin, up); + Math3D.VectorCopy(pml.origin, up); // decide which one went farther down_dist = (down_o[0] - start_o[0]) * (down_o[0] - start_o[0]) @@ -280,21 +254,18 @@ public class PMove { up_dist = (up[0] - start_o[0]) * (up[0] - start_o[0]) + (up[1] - start_o[1]) * (up[1] - start_o[1]); - if (down_dist > up_dist - || trace.plane.normal[2] < Defines.MIN_STEP_NORMAL) { - Math3D.VectorCopy(down_o, PMove.pml.origin); - Math3D.VectorCopy(down_v, PMove.pml.velocity); + if (down_dist > up_dist || trace.plane.normal[2] < Defines.MIN_STEP_NORMAL) { + Math3D.VectorCopy(down_o, pml.origin); + Math3D.VectorCopy(down_v, pml.velocity); return; } //!! Special case // if we were walking along a plane, then we need to copy the Z over - PMove.pml.velocity[2] = down_v[2]; + pml.velocity[2] = down_v[2]; } - /* - * ================== PM_Friction - * - * Handles both ground friction and water friction ================== + /** + * Handles both ground friction and water friction. */ public static void PM_Friction() { float vel[]; @@ -302,10 +273,9 @@ public class PMove { float friction; float drop; - vel = PMove.pml.velocity; + vel = pml.velocity; - speed = (float) (Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] - * vel[2])); + speed = (float) (Math.sqrt(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2])); if (speed < 1) { vel[0] = 0; vel[1] = 0; @@ -315,17 +285,18 @@ public class PMove { drop = 0; // apply ground friction - if ((PMove.pm.groundentity != null && PMove.pml.groundsurface != null && 0 == (PMove.pml.groundsurface.flags & Defines.SURF_SLICK)) - || (PMove.pml.ladder)) { - friction = PMove.pm_friction; - control = speed < PMove.pm_stopspeed ? PMove.pm_stopspeed : speed; - drop += control * friction * PMove.pml.frametime; + if ((pm.groundentity != null && pml.groundsurface != null && + 0 == (pml.groundsurface.flags & Defines.SURF_SLICK)) + || (pml.ladder)) { + friction = pm_friction; + control = speed < pm_stopspeed ? pm_stopspeed : speed; + drop += control * friction * pml.frametime; } // apply water friction - if (PMove.pm.waterlevel != 0 && !PMove.pml.ladder) - drop += speed * PMove.pm_waterfriction * PMove.pm.waterlevel - * PMove.pml.frametime; + if (pm.waterlevel != 0 && !pml.ladder) + drop += speed * pm_waterfriction * pm.waterlevel + * pml.frametime; // scale the velocity newspeed = speed - drop; @@ -339,27 +310,29 @@ public class PMove { vel[2] = vel[2] * newspeed; } - /* - * ============== PM_Accelerate - * - * Handles user intended acceleration ============== + /** + * Handles user intended acceleration. */ public static void PM_Accelerate(float[] wishdir, float wishspeed, float accel) { int i; float addspeed, accelspeed, currentspeed; - currentspeed = Math3D.DotProduct(PMove.pml.velocity, wishdir); + currentspeed = Math3D.DotProduct(pml.velocity, wishdir); addspeed = wishspeed - currentspeed; if (addspeed <= 0) return; - accelspeed = accel * PMove.pml.frametime * wishspeed; + accelspeed = accel * pml.frametime * wishspeed; if (accelspeed > addspeed) accelspeed = addspeed; for (i = 0; i < 3; i++) - PMove.pml.velocity[i] += accelspeed * wishdir[i]; + pml.velocity[i] += accelspeed * wishdir[i]; } + + /** + * PM_AirAccelerate. + */ public static void PM_AirAccelerate(float[] wishdir, float wishspeed, float accel) { @@ -368,39 +341,36 @@ public class PMove { if (wishspd > 30) wishspd = 30; - currentspeed = Math3D.DotProduct(PMove.pml.velocity, wishdir); + currentspeed = Math3D.DotProduct(pml.velocity, wishdir); addspeed = wishspd - currentspeed; if (addspeed <= 0) return; - accelspeed = accel * wishspeed * PMove.pml.frametime; + accelspeed = accel * wishspeed * pml.frametime; if (accelspeed > addspeed) accelspeed = addspeed; for (i = 0; i < 3; i++) - PMove.pml.velocity[i] += accelspeed * wishdir[i]; + pml.velocity[i] += accelspeed * wishdir[i]; } - /* - * ============= PM_AddCurrents ============= + /** + * PM_AddCurrents. */ public static void PM_AddCurrents(float[] wishvel) { float[] v = { 0, 0, 0 }; float s; - // // account for ladders - // - - if (PMove.pml.ladder && Math.abs(PMove.pml.velocity[2]) <= 200) { - if ((PMove.pm.viewangles[Defines.PITCH] <= -15) - && (PMove.pm.cmd.forwardmove > 0)) + if (pml.ladder && Math.abs(pml.velocity[2]) <= 200) { + if ((pm.viewangles[Defines.PITCH] <= -15) + && (pm.cmd.forwardmove > 0)) wishvel[2] = 200; - else if ((PMove.pm.viewangles[Defines.PITCH] >= 15) - && (PMove.pm.cmd.forwardmove > 0)) + else if ((pm.viewangles[Defines.PITCH] >= 15) + && (pm.cmd.forwardmove > 0)) wishvel[2] = -200; - else if (PMove.pm.cmd.upmove > 0) + else if (pm.cmd.upmove > 0) wishvel[2] = 200; - else if (PMove.pm.cmd.upmove < 0) + else if (pm.cmd.upmove < 0) wishvel[2] = -200; else wishvel[2] = 0; @@ -417,62 +387,53 @@ public class PMove { wishvel[1] = 25; } - // // add water currents - // - - if ((PMove.pm.watertype & Defines.MASK_CURRENT) != 0) { + if ((pm.watertype & Defines.MASK_CURRENT) != 0) { Math3D.VectorClear(v); - if ((PMove.pm.watertype & Defines.CONTENTS_CURRENT_0) != 0) + if ((pm.watertype & Defines.CONTENTS_CURRENT_0) != 0) v[0] += 1; - if ((PMove.pm.watertype & Defines.CONTENTS_CURRENT_90) != 0) + if ((pm.watertype & Defines.CONTENTS_CURRENT_90) != 0) v[1] += 1; - if ((PMove.pm.watertype & Defines.CONTENTS_CURRENT_180) != 0) + if ((pm.watertype & Defines.CONTENTS_CURRENT_180) != 0) v[0] -= 1; - if ((PMove.pm.watertype & Defines.CONTENTS_CURRENT_270) != 0) + if ((pm.watertype & Defines.CONTENTS_CURRENT_270) != 0) v[1] -= 1; - if ((PMove.pm.watertype & Defines.CONTENTS_CURRENT_UP) != 0) + if ((pm.watertype & Defines.CONTENTS_CURRENT_UP) != 0) v[2] += 1; - if ((PMove.pm.watertype & Defines.CONTENTS_CURRENT_DOWN) != 0) + if ((pm.watertype & Defines.CONTENTS_CURRENT_DOWN) != 0) v[2] -= 1; - s = PMove.pm_waterspeed; - if ((PMove.pm.waterlevel == 1) && (PMove.pm.groundentity != null)) + s = pm_waterspeed; + if ((pm.waterlevel == 1) && (pm.groundentity != null)) s /= 2; Math3D.VectorMA(wishvel, s, v, wishvel); } - // // add conveyor belt velocities - // - - if (PMove.pm.groundentity != null) { + if (pm.groundentity != null) { Math3D.VectorClear(v); - if ((PMove.pml.groundcontents & Defines.CONTENTS_CURRENT_0) != 0) + if ((pml.groundcontents & Defines.CONTENTS_CURRENT_0) != 0) v[0] += 1; - if ((PMove.pml.groundcontents & Defines.CONTENTS_CURRENT_90) != 0) + if ((pml.groundcontents & Defines.CONTENTS_CURRENT_90) != 0) v[1] += 1; - if ((PMove.pml.groundcontents & Defines.CONTENTS_CURRENT_180) != 0) + if ((pml.groundcontents & Defines.CONTENTS_CURRENT_180) != 0) v[0] -= 1; - if ((PMove.pml.groundcontents & Defines.CONTENTS_CURRENT_270) != 0) + if ((pml.groundcontents & Defines.CONTENTS_CURRENT_270) != 0) v[1] -= 1; - if ((PMove.pml.groundcontents & Defines.CONTENTS_CURRENT_UP) != 0) + if ((pml.groundcontents & Defines.CONTENTS_CURRENT_UP) != 0) v[2] += 1; - if ((PMove.pml.groundcontents & Defines.CONTENTS_CURRENT_DOWN) != 0) + if ((pml.groundcontents & Defines.CONTENTS_CURRENT_DOWN) != 0) v[2] -= 1; - Math3D.VectorMA(wishvel, 100 /* pm.groundentity.speed */ - , v, wishvel); + Math3D.VectorMA(wishvel, 100 /* pm.groundentity.speed */, v, wishvel); } } - /* - * =================== PM_WaterMove - * - * =================== + /** + * PM_WaterMove. */ public static void PM_WaterMove() { int i; @@ -480,54 +441,50 @@ public class PMove { float wishspeed; float[] wishdir = { 0, 0, 0 }; - // + // user intentions - // for (i = 0; i < 3; i++) - wishvel[i] = PMove.pml.forward[i] * PMove.pm.cmd.forwardmove - + PMove.pml.right[i] * PMove.pm.cmd.sidemove; + wishvel[i] = pml.forward[i] * pm.cmd.forwardmove + + pml.right[i] * pm.cmd.sidemove; - if (0 == PMove.pm.cmd.forwardmove && 0 == PMove.pm.cmd.sidemove - && 0 == PMove.pm.cmd.upmove) + if (0 == pm.cmd.forwardmove && 0 == pm.cmd.sidemove + && 0 == pm.cmd.upmove) wishvel[2] -= 60; // drift towards bottom else - wishvel[2] += PMove.pm.cmd.upmove; + wishvel[2] += pm.cmd.upmove; PM_AddCurrents(wishvel); Math3D.VectorCopy(wishvel, wishdir); wishspeed = Math3D.VectorNormalize(wishdir); - if (wishspeed > PMove.pm_maxspeed) { - Math3D.VectorScale(wishvel, PMove.pm_maxspeed / wishspeed, wishvel); - wishspeed = PMove.pm_maxspeed; + if (wishspeed > pm_maxspeed) { + Math3D.VectorScale(wishvel, pm_maxspeed / wishspeed, wishvel); + wishspeed = pm_maxspeed; } wishspeed *= 0.5; - PM_Accelerate(wishdir, wishspeed, PMove.pm_wateraccelerate); + PM_Accelerate(wishdir, wishspeed, pm_wateraccelerate); PM_StepSlideMove(); } - /* - * =================== PM_AirMove - * - * =================== + /** + * PM_AirMove. */ public static void PM_AirMove() { - int i; float[] wishvel = { 0, 0, 0 }; float fmove, smove; float[] wishdir = { 0, 0, 0 }; float wishspeed; float maxspeed; - fmove = PMove.pm.cmd.forwardmove; - smove = PMove.pm.cmd.sidemove; + fmove = pm.cmd.forwardmove; + smove = pm.cmd.sidemove; - for (i = 0; i < 2; i++) - wishvel[i] = PMove.pml.forward[i] * fmove + PMove.pml.right[i] - * smove; + wishvel[0] = pml.forward[0] * fmove + pml.right[0] * smove; + wishvel[1] = pml.forward[1] * fmove + pml.right[1] * smove; + wishvel[2] = 0; PM_AddCurrents(wishvel); @@ -535,62 +492,57 @@ public class PMove { Math3D.VectorCopy(wishvel, wishdir); wishspeed = Math3D.VectorNormalize(wishdir); - // + // clamp to server defined max speed - // - maxspeed = (PMove.pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0 ? PMove.pm_duckspeed - : PMove.pm_maxspeed; + maxspeed = (pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0 ? pm_duckspeed + : pm_maxspeed; if (wishspeed > maxspeed) { Math3D.VectorScale(wishvel, maxspeed / wishspeed, wishvel); wishspeed = maxspeed; } - if (PMove.pml.ladder) { - PM_Accelerate(wishdir, wishspeed, PMove.pm_accelerate); + if (pml.ladder) { + PM_Accelerate(wishdir, wishspeed, pm_accelerate); if (0 == wishvel[2]) { - if (PMove.pml.velocity[2] > 0) { - PMove.pml.velocity[2] -= PMove.pm.s.gravity - * PMove.pml.frametime; - if (PMove.pml.velocity[2] < 0) - PMove.pml.velocity[2] = 0; + if (pml.velocity[2] > 0) { + pml.velocity[2] -= pm.s.gravity * pml.frametime; + if (pml.velocity[2] < 0) + pml.velocity[2] = 0; } else { - PMove.pml.velocity[2] += PMove.pm.s.gravity - * PMove.pml.frametime; - if (PMove.pml.velocity[2] > 0) - PMove.pml.velocity[2] = 0; + pml.velocity[2] += pm.s.gravity * pml.frametime; + if (pml.velocity[2] > 0) + pml.velocity[2] = 0; } } PM_StepSlideMove(); - } else if (PMove.pm.groundentity != null) { // walking on ground - PMove.pml.velocity[2] = 0; //!!! this is before the accel - PM_Accelerate(wishdir, wishspeed, PMove.pm_accelerate); + } else if (pm.groundentity != null) { // walking on ground + pml.velocity[2] = 0; //!!! this is before the accel + PM_Accelerate(wishdir, wishspeed, pm_accelerate); // PGM -- fix for negative trigger_gravity fields // pml.velocity[2] = 0; - if (PMove.pm.s.gravity > 0) - PMove.pml.velocity[2] = 0; + if (pm.s.gravity > 0) + pml.velocity[2] = 0; else - PMove.pml.velocity[2] -= PMove.pm.s.gravity - * PMove.pml.frametime; + pml.velocity[2] -= pm.s.gravity * pml.frametime; // PGM - - if (0 == PMove.pml.velocity[0] && 0 == PMove.pml.velocity[1]) + if (0 == pml.velocity[0] && 0 == pml.velocity[1]) return; PM_StepSlideMove(); } else { // not on ground, so little effect on velocity - if (PMove.pm_airaccelerate != 0) - PM_AirAccelerate(wishdir, wishspeed, PMove.pm_accelerate); + if (pm_airaccelerate != 0) + PM_AirAccelerate(wishdir, wishspeed, pm_accelerate); else PM_Accelerate(wishdir, wishspeed, 1); // add gravity - PMove.pml.velocity[2] -= PMove.pm.s.gravity * PMove.pml.frametime; + pml.velocity[2] -= pm.s.gravity * pml.frametime; PM_StepSlideMove(); } } - /* - * ============= PM_CatagorizePosition ============= + /** + * PM_CatagorizePosition. */ public static void PM_CatagorizePosition() { float[] point = { 0, 0, 0 }; @@ -603,133 +555,132 @@ public class PMove { // is on ground // see if standing on something solid - point[0] = PMove.pml.origin[0]; - point[1] = PMove.pml.origin[1]; - point[2] = PMove.pml.origin[2] - 0.25f; - if (PMove.pml.velocity[2] > 180) //!!ZOID changed from 100 to 180 (ramp + point[0] = pml.origin[0]; + point[1] = pml.origin[1]; + point[2] = pml.origin[2] - 0.25f; + if (pml.velocity[2] > 180) //!!ZOID changed from 100 to 180 (ramp // accel) { - PMove.pm.s.pm_flags &= ~pmove_t.PMF_ON_GROUND; - PMove.pm.groundentity = null; + pm.s.pm_flags &= ~pmove_t.PMF_ON_GROUND; + pm.groundentity = null; } else { - trace = PMove.pm.trace.trace(PMove.pml.origin, PMove.pm.mins, - PMove.pm.maxs, point); - PMove.pml.groundsurface = trace.surface; - PMove.pml.groundcontents = trace.contents; + trace = pm.trace.trace(pml.origin, pm.mins, + pm.maxs, point); + pml.groundsurface = trace.surface; + pml.groundcontents = trace.contents; if (null == trace.ent || (trace.plane.normal[2] < 0.7 && !trace.startsolid)) { - PMove.pm.groundentity = null; - PMove.pm.s.pm_flags &= ~pmove_t.PMF_ON_GROUND; + pm.groundentity = null; + pm.s.pm_flags &= ~pmove_t.PMF_ON_GROUND; } else { - PMove.pm.groundentity = trace.ent; + pm.groundentity = trace.ent; // hitting solid ground will end a waterjump - if ((PMove.pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0) { - PMove.pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP + if ((pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0) { + pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT); - PMove.pm.s.pm_time = 0; + pm.s.pm_time = 0; } - if (0 == (PMove.pm.s.pm_flags & pmove_t.PMF_ON_GROUND)) { // just - // hit - // the - // ground - PMove.pm.s.pm_flags |= pmove_t.PMF_ON_GROUND; + if (0 == (pm.s.pm_flags & pmove_t.PMF_ON_GROUND)) { + + // just hit the ground + pm.s.pm_flags |= pmove_t.PMF_ON_GROUND; // don't do landing time if we were just going down a slope - if (PMove.pml.velocity[2] < -200) { - PMove.pm.s.pm_flags |= pmove_t.PMF_TIME_LAND; + if (pml.velocity[2] < -200) { + pm.s.pm_flags |= pmove_t.PMF_TIME_LAND; // don't allow another jump for a little while - if (PMove.pml.velocity[2] < -400) - PMove.pm.s.pm_time = 25; + if (pml.velocity[2] < -400) + pm.s.pm_time = 25; else - PMove.pm.s.pm_time = 18; + pm.s.pm_time = 18; } } } - if (PMove.pm.numtouch < Defines.MAXTOUCH && trace.ent != null) { - PMove.pm.touchents[PMove.pm.numtouch] = trace.ent; - PMove.pm.numtouch++; + if (pm.numtouch < Defines.MAXTOUCH && trace.ent != null) { + pm.touchents[pm.numtouch] = trace.ent; + pm.numtouch++; } } - // + // get waterlevel, accounting for ducking - // - PMove.pm.waterlevel = 0; - PMove.pm.watertype = 0; + + pm.waterlevel = 0; + pm.watertype = 0; - sample2 = (int) (PMove.pm.viewheight - PMove.pm.mins[2]); + sample2 = (int) (pm.viewheight - pm.mins[2]); sample1 = sample2 / 2; - point[2] = PMove.pml.origin[2] + PMove.pm.mins[2] + 1; - cont = PMove.pm.pointcontents.pointcontents(point); + point[2] = pml.origin[2] + pm.mins[2] + 1; + cont = pm.pointcontents.pointcontents(point); if ((cont & Defines.MASK_WATER) != 0) { - PMove.pm.watertype = cont; - PMove.pm.waterlevel = 1; - point[2] = PMove.pml.origin[2] + PMove.pm.mins[2] + sample1; - cont = PMove.pm.pointcontents.pointcontents(point); + pm.watertype = cont; + pm.waterlevel = 1; + point[2] = pml.origin[2] + pm.mins[2] + sample1; + cont = pm.pointcontents.pointcontents(point); if ((cont & Defines.MASK_WATER) != 0) { - PMove.pm.waterlevel = 2; - point[2] = PMove.pml.origin[2] + PMove.pm.mins[2] + sample2; - cont = PMove.pm.pointcontents.pointcontents(point); + pm.waterlevel = 2; + point[2] = pml.origin[2] + pm.mins[2] + sample2; + cont = pm.pointcontents.pointcontents(point); if ((cont & Defines.MASK_WATER) != 0) - PMove.pm.waterlevel = 3; + pm.waterlevel = 3; } } } - /* - * ============= PM_CheckJump ============= + /** + * PM_CheckJump. */ public static void PM_CheckJump() { - if ((PMove.pm.s.pm_flags & pmove_t.PMF_TIME_LAND) != 0) { + if ((pm.s.pm_flags & pmove_t.PMF_TIME_LAND) != 0) { // hasn't been long enough since landing to jump again return; } - if (PMove.pm.cmd.upmove < 10) { // not holding jump - PMove.pm.s.pm_flags &= ~pmove_t.PMF_JUMP_HELD; + if (pm.cmd.upmove < 10) { // not holding jump + pm.s.pm_flags &= ~pmove_t.PMF_JUMP_HELD; return; } // must wait for jump to be released - if ((PMove.pm.s.pm_flags & pmove_t.PMF_JUMP_HELD) != 0) + if ((pm.s.pm_flags & pmove_t.PMF_JUMP_HELD) != 0) return; - if (PMove.pm.s.pm_type == Defines.PM_DEAD) + if (pm.s.pm_type == Defines.PM_DEAD) return; - if (PMove.pm.waterlevel >= 2) { // swimming, not jumping - PMove.pm.groundentity = null; + if (pm.waterlevel >= 2) { // swimming, not jumping + pm.groundentity = null; - if (PMove.pml.velocity[2] <= -300) + if (pml.velocity[2] <= -300) return; - if (PMove.pm.watertype == Defines.CONTENTS_WATER) - PMove.pml.velocity[2] = 100; - else if (PMove.pm.watertype == Defines.CONTENTS_SLIME) - PMove.pml.velocity[2] = 80; + if (pm.watertype == Defines.CONTENTS_WATER) + pml.velocity[2] = 100; + else if (pm.watertype == Defines.CONTENTS_SLIME) + pml.velocity[2] = 80; else - PMove.pml.velocity[2] = 50; + pml.velocity[2] = 50; return; } - if (PMove.pm.groundentity == null) + if (pm.groundentity == null) return; // in air, so no effect - PMove.pm.s.pm_flags |= pmove_t.PMF_JUMP_HELD; + pm.s.pm_flags |= pmove_t.PMF_JUMP_HELD; - PMove.pm.groundentity = null; - PMove.pml.velocity[2] += 270; - if (PMove.pml.velocity[2] < 270) - PMove.pml.velocity[2] = 270; + pm.groundentity = null; + pml.velocity[2] += 270; + if (pml.velocity[2] < 270) + pml.velocity[2] = 270; } - /* - * ============= PM_CheckSpecialMovement ============= + /** + * PM_CheckSpecialMovement. */ public static void PM_CheckSpecialMovement() { float[] spot = { 0, 0, 0 }; @@ -737,48 +688,48 @@ public class PMove { float[] flatforward = { 0, 0, 0 }; trace_t trace; - if (PMove.pm.s.pm_time != 0) + if (pm.s.pm_time != 0) return; - PMove.pml.ladder = false; + pml.ladder = false; // check for ladder - flatforward[0] = PMove.pml.forward[0]; - flatforward[1] = PMove.pml.forward[1]; + flatforward[0] = pml.forward[0]; + flatforward[1] = pml.forward[1]; flatforward[2] = 0; Math3D.VectorNormalize(flatforward); - Math3D.VectorMA(PMove.pml.origin, 1, flatforward, spot); - trace = PMove.pm.trace.trace(PMove.pml.origin, PMove.pm.mins, - PMove.pm.maxs, spot); + Math3D.VectorMA(pml.origin, 1, flatforward, spot); + trace = pm.trace.trace(pml.origin, pm.mins, + pm.maxs, spot); if ((trace.fraction < 1) && (trace.contents & Defines.CONTENTS_LADDER) != 0) - PMove.pml.ladder = true; + pml.ladder = true; // check for water jump - if (PMove.pm.waterlevel != 2) + if (pm.waterlevel != 2) return; - Math3D.VectorMA(PMove.pml.origin, 30, flatforward, spot); + Math3D.VectorMA(pml.origin, 30, flatforward, spot); spot[2] += 4; - cont = PMove.pm.pointcontents.pointcontents(spot); + cont = pm.pointcontents.pointcontents(spot); if (0 == (cont & Defines.CONTENTS_SOLID)) return; spot[2] += 16; - cont = PMove.pm.pointcontents.pointcontents(spot); + cont = pm.pointcontents.pointcontents(spot); if (cont != 0) return; // jump out of water - Math3D.VectorScale(flatforward, 50, PMove.pml.velocity); - PMove.pml.velocity[2] = 350; + Math3D.VectorScale(flatforward, 50, pml.velocity); + pml.velocity[2] = 350; - PMove.pm.s.pm_flags |= pmove_t.PMF_TIME_WATERJUMP; - PMove.pm.s.pm_time = -1; // was 255 + pm.s.pm_flags |= pmove_t.PMF_TIME_WATERJUMP; + pm.s.pm_time = -1; // was 255 } - /* - * =============== PM_FlyMove =============== + /** + * PM_FlyMove. */ public static void PM_FlyMove(boolean doclip) { float speed, drop, friction, control, newspeed; @@ -791,19 +742,19 @@ public class PMove { float[] end = { 0, 0, 0 }; trace_t trace; - PMove.pm.viewheight = 22; + pm.viewheight = 22; // friction - speed = Math3D.VectorLength(PMove.pml.velocity); + speed = Math3D.VectorLength(pml.velocity); if (speed < 1) { - Math3D.VectorCopy(Globals.vec3_origin, PMove.pml.velocity); + Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); } else { drop = 0; - friction = PMove.pm_friction * 1.5f; // extra friction - control = speed < PMove.pm_stopspeed ? PMove.pm_stopspeed : speed; - drop += control * friction * PMove.pml.frametime; + friction = pm_friction * 1.5f; // extra friction + control = speed < pm_stopspeed ? pm_stopspeed : speed; + drop += control * friction * pml.frametime; // scale the velocity newspeed = speed - drop; @@ -811,127 +762,115 @@ public class PMove { newspeed = 0; newspeed /= speed; - Math3D - .VectorScale(PMove.pml.velocity, newspeed, - PMove.pml.velocity); + Math3D.VectorScale(pml.velocity, newspeed, pml.velocity); } // accelerate - fmove = PMove.pm.cmd.forwardmove; - smove = PMove.pm.cmd.sidemove; + fmove = pm.cmd.forwardmove; + smove = pm.cmd.sidemove; - Math3D.VectorNormalize(PMove.pml.forward); - Math3D.VectorNormalize(PMove.pml.right); + Math3D.VectorNormalize(pml.forward); + Math3D.VectorNormalize(pml.right); for (i = 0; i < 3; i++) - wishvel[i] = PMove.pml.forward[i] * fmove + PMove.pml.right[i] + wishvel[i] = pml.forward[i] * fmove + pml.right[i] * smove; - wishvel[2] += PMove.pm.cmd.upmove; + wishvel[2] += pm.cmd.upmove; Math3D.VectorCopy(wishvel, wishdir); wishspeed = Math3D.VectorNormalize(wishdir); - // // clamp to server defined max speed - // - if (wishspeed > PMove.pm_maxspeed) { - Math3D.VectorScale(wishvel, PMove.pm_maxspeed / wishspeed, wishvel); - wishspeed = PMove.pm_maxspeed; + if (wishspeed > pm_maxspeed) { + Math3D.VectorScale(wishvel, pm_maxspeed / wishspeed, wishvel); + wishspeed = pm_maxspeed; } - currentspeed = Math3D.DotProduct(PMove.pml.velocity, wishdir); + currentspeed = Math3D.DotProduct(pml.velocity, wishdir); addspeed = wishspeed - currentspeed; if (addspeed <= 0) return; - accelspeed = PMove.pm_accelerate * PMove.pml.frametime * wishspeed; + accelspeed = pm_accelerate * pml.frametime * wishspeed; if (accelspeed > addspeed) accelspeed = addspeed; for (i = 0; i < 3; i++) - PMove.pml.velocity[i] += accelspeed * wishdir[i]; + pml.velocity[i] += accelspeed * wishdir[i]; if (doclip) { for (i = 0; i < 3; i++) - end[i] = PMove.pml.origin[i] + PMove.pml.frametime - * PMove.pml.velocity[i]; + end[i] = pml.origin[i] + pml.frametime * pml.velocity[i]; - trace = PMove.pm.trace.trace(PMove.pml.origin, PMove.pm.mins, - PMove.pm.maxs, end); + trace = pm.trace.trace(pml.origin, pm.mins, pm.maxs, end); - Math3D.VectorCopy(trace.endpos, PMove.pml.origin); + Math3D.VectorCopy(trace.endpos, pml.origin); } else { // move - Math3D.VectorMA(PMove.pml.origin, PMove.pml.frametime, - PMove.pml.velocity, PMove.pml.origin); + Math3D.VectorMA(pml.origin, pml.frametime, pml.velocity, pml.origin); } } - /* - * ============== PM_CheckDuck - * - * Sets mins, maxs, and pm.viewheight ============== + /** + * Sets mins, maxs, and pm.viewheight. */ public static void PM_CheckDuck() { trace_t trace; - PMove.pm.mins[0] = -16; - PMove.pm.mins[1] = -16; + pm.mins[0] = -16; + pm.mins[1] = -16; - PMove.pm.maxs[0] = 16; - PMove.pm.maxs[1] = 16; + pm.maxs[0] = 16; + pm.maxs[1] = 16; - if (PMove.pm.s.pm_type == Defines.PM_GIB) { - PMove.pm.mins[2] = 0; - PMove.pm.maxs[2] = 16; - PMove.pm.viewheight = 8; + if (pm.s.pm_type == Defines.PM_GIB) { + pm.mins[2] = 0; + pm.maxs[2] = 16; + pm.viewheight = 8; return; } - PMove.pm.mins[2] = -24; + pm.mins[2] = -24; - if (PMove.pm.s.pm_type == Defines.PM_DEAD) { - PMove.pm.s.pm_flags |= pmove_t.PMF_DUCKED; - } else if (PMove.pm.cmd.upmove < 0 - && (PMove.pm.s.pm_flags & pmove_t.PMF_ON_GROUND) != 0) { // duck - PMove.pm.s.pm_flags |= pmove_t.PMF_DUCKED; + if (pm.s.pm_type == Defines.PM_DEAD) { + pm.s.pm_flags |= pmove_t.PMF_DUCKED; + } else if (pm.cmd.upmove < 0 && (pm.s.pm_flags & pmove_t.PMF_ON_GROUND) != 0) { // duck + pm.s.pm_flags |= pmove_t.PMF_DUCKED; } else { // stand up if possible - if ((PMove.pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0) { + if ((pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0) { // try to stand up - PMove.pm.maxs[2] = 32; - trace = PMove.pm.trace.trace(PMove.pml.origin, PMove.pm.mins, - PMove.pm.maxs, PMove.pml.origin); + pm.maxs[2] = 32; + trace = pm.trace.trace(pml.origin, pm.mins, pm.maxs, pml.origin); if (!trace.allsolid) - PMove.pm.s.pm_flags &= ~pmove_t.PMF_DUCKED; + pm.s.pm_flags &= ~pmove_t.PMF_DUCKED; } } - if ((PMove.pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0) { - PMove.pm.maxs[2] = 4; - PMove.pm.viewheight = -2; + if ((pm.s.pm_flags & pmove_t.PMF_DUCKED) != 0) { + pm.maxs[2] = 4; + pm.viewheight = -2; } else { - PMove.pm.maxs[2] = 32; - PMove.pm.viewheight = 22; + pm.maxs[2] = 32; + pm.viewheight = 22; } } - /* - * ============== PM_DeadMove ============== + /** + * Dead bodies have extra friction. */ public static void PM_DeadMove() { float forward; - if (null == PMove.pm.groundentity) + if (null == pm.groundentity) return; // extra friction - - forward = Math3D.VectorLength(PMove.pml.velocity); + forward = Math3D.VectorLength(pml.velocity); forward -= 20; if (forward <= 0) { - Math3D.VectorClear(PMove.pml.velocity); + Math3D.VectorClear(pml.velocity); } else { - Math3D.VectorNormalize(PMove.pml.velocity); - Math3D.VectorScale(PMove.pml.velocity, forward, PMove.pml.velocity); + Math3D.VectorNormalize(pml.velocity); + Math3D.VectorScale(pml.velocity, forward, pml.velocity); } } @@ -940,16 +879,21 @@ public class PMove { float[] origin = { 0, 0, 0 }, end = { 0, 0, 0 }; int i; - if (PMove.pm.s.pm_type == Defines.PM_SPECTATOR) + if (pm.s.pm_type == Defines.PM_SPECTATOR) return true; for (i = 0; i < 3; i++) - origin[i] = end[i] = PMove.pm.s.origin[i] * 0.125f; - trace = PMove.pm.trace.trace(origin, PMove.pm.mins, PMove.pm.maxs, end); + origin[i] = end[i] = pm.s.origin[i] * 0.125f; + trace = pm.trace.trace(origin, pm.mins, pm.maxs, end); return !trace.allsolid; } + /** + * On exit, the origin will have a value that is pre-quantized to the 0.125 + * precision of the network channel and in a valid position. + */ + public static void PM_SnapPosition() { int sign[] = { 0, 0, 0 }; int i, j, bits; @@ -957,54 +901,57 @@ public class PMove { // snap velocity to eigths for (i = 0; i < 3; i++) - PMove.pm.s.velocity[i] = (short) (PMove.pml.velocity[i] * 8); + pm.s.velocity[i] = (short) (pml.velocity[i] * 8); for (i = 0; i < 3; i++) { - if (PMove.pml.origin[i] >= 0) + if (pml.origin[i] >= 0) sign[i] = 1; else sign[i] = -1; - PMove.pm.s.origin[i] = (short) (PMove.pml.origin[i] * 8); - if (PMove.pm.s.origin[i] * 0.125 == PMove.pml.origin[i]) + pm.s.origin[i] = (short) (pml.origin[i] * 8); + if (pm.s.origin[i] * 0.125 == pml.origin[i]) sign[i] = 0; } - Math3D.VectorCopy(PMove.pm.s.origin, base); + Math3D.VectorCopy(pm.s.origin, base); // try all combinations for (j = 0; j < 8; j++) { bits = jitterbits[j]; - Math3D.VectorCopy(base, PMove.pm.s.origin); + Math3D.VectorCopy(base, pm.s.origin); for (i = 0; i < 3; i++) if ((bits & (1 << i)) != 0) - PMove.pm.s.origin[i] += sign[i]; + pm.s.origin[i] += sign[i]; - if (PMove.PM_GoodPosition()) + if (PM_GoodPosition()) return; } // go back to the last position - Math3D.VectorCopy(PMove.pml.previous_origin, PMove.pm.s.origin); - // Com_DPrintf ("using previous_origin\n"); + Math3D.VectorCopy(pml.previous_origin, pm.s.origin); + // Com.DPrintf("using previous_origin\n"); } + /** + * Snaps the origin of the player move to 0.125 grid. + */ public static void PM_InitialSnapPosition() { int x, y, z; short base[] = { 0, 0, 0 }; - Math3D.VectorCopy(PMove.pm.s.origin, base); + Math3D.VectorCopy(pm.s.origin, base); for (z = 0; z < 3; z++) { - PMove.pm.s.origin[2] = (short) (base[2] + offset[z]); + pm.s.origin[2] = (short) (base[2] + offset[z]); for (y = 0; y < 3; y++) { - PMove.pm.s.origin[1] = (short) (base[1] + offset[y]); + pm.s.origin[1] = (short) (base[1] + offset[y]); for (x = 0; x < 3; x++) { - PMove.pm.s.origin[0] = (short) (base[0] + offset[x]); - if (PMove.PM_GoodPosition()) { - PMove.pml.origin[0] = PMove.pm.s.origin[0] * 0.125f; - PMove.pml.origin[1] = PMove.pm.s.origin[1] * 0.125f; - PMove.pml.origin[2] = PMove.pm.s.origin[2] * 0.125f; - Math3D.VectorCopy(PMove.pm.s.origin, - PMove.pml.previous_origin); + pm.s.origin[0] = (short) (base[0] + offset[x]); + if (PM_GoodPosition()) { + pml.origin[0] = pm.s.origin[0] * 0.125f; + pml.origin[1] = pm.s.origin[1] * 0.125f; + pml.origin[2] = pm.s.origin[2] * 0.125f; + Math3D.VectorCopy(pm.s.origin, + pml.previous_origin); return; } } @@ -1014,166 +961,151 @@ public class PMove { Com.DPrintf("Bad InitialSnapPosition\n"); } - /* - * ================ PM_ClampAngles - * - * ================ + /** + * PM_ClampAngles. */ public static void PM_ClampAngles() { short temp; int i; - if ((PMove.pm.s.pm_flags & pmove_t.PMF_TIME_TELEPORT) != 0) { - PMove.pm.viewangles[Defines.YAW] = Math3D - .SHORT2ANGLE(PMove.pm.cmd.angles[Defines.YAW] - + PMove.pm.s.delta_angles[Defines.YAW]); - PMove.pm.viewangles[Defines.PITCH] = 0; - PMove.pm.viewangles[Defines.ROLL] = 0; + if ((pm.s.pm_flags & pmove_t.PMF_TIME_TELEPORT) != 0) { + pm.viewangles[Defines.YAW] = Math3D + .SHORT2ANGLE(pm.cmd.angles[Defines.YAW] + + pm.s.delta_angles[Defines.YAW]); + pm.viewangles[Defines.PITCH] = 0; + pm.viewangles[Defines.ROLL] = 0; } else { // circularly clamp the angles with deltas for (i = 0; i < 3; i++) { - temp = (short) (PMove.pm.cmd.angles[i] + PMove.pm.s.delta_angles[i]); - PMove.pm.viewangles[i] = Math3D.SHORT2ANGLE(temp); + temp = (short) (pm.cmd.angles[i] + pm.s.delta_angles[i]); + pm.viewangles[i] = Math3D.SHORT2ANGLE(temp); } // don't let the player look up or down more than 90 degrees - if (PMove.pm.viewangles[Defines.PITCH] > 89 - && PMove.pm.viewangles[Defines.PITCH] < 180) - PMove.pm.viewangles[Defines.PITCH] = 89; - else if (PMove.pm.viewangles[Defines.PITCH] < 271 - && PMove.pm.viewangles[Defines.PITCH] >= 180) - PMove.pm.viewangles[Defines.PITCH] = 271; + if (pm.viewangles[Defines.PITCH] > 89 && pm.viewangles[Defines.PITCH] < 180) + pm.viewangles[Defines.PITCH] = 89; + else if (pm.viewangles[Defines.PITCH] < 271 && pm.viewangles[Defines.PITCH] >= 180) + pm.viewangles[Defines.PITCH] = 271; } - Math3D.AngleVectors(PMove.pm.viewangles, PMove.pml.forward, - PMove.pml.right, PMove.pml.up); + Math3D.AngleVectors(pm.viewangles, pml.forward, pml.right, pml.up); } - /* - * ================ Pmove - * - * Can be called by either the server or the client ================ + /** + * Can be called by either the server or the client. */ public static void Pmove(pmove_t pmove) { - PMove.pm = pmove; + pm = pmove; // clear results - PMove.pm.numtouch = 0; - Math3D.VectorClear(PMove.pm.viewangles); - PMove.pm.viewheight = 0; - PMove.pm.groundentity = null; - PMove.pm.watertype = 0; - PMove.pm.waterlevel = 0; + pm.numtouch = 0; + Math3D.VectorClear(pm.viewangles); + pm.viewheight = 0; + pm.groundentity = null; + pm.watertype = 0; + pm.waterlevel = 0; - PMove.pml.groundsurface = null; - PMove.pml.groundcontents = 0; + pml.groundsurface = null; + pml.groundcontents = 0; // convert origin and velocity to float values - PMove.pml.origin[0] = PMove.pm.s.origin[0] * 0.125f; - PMove.pml.origin[1] = PMove.pm.s.origin[1] * 0.125f; - PMove.pml.origin[2] = PMove.pm.s.origin[2] * 0.125f; + pml.origin[0] = pm.s.origin[0] * 0.125f; + pml.origin[1] = pm.s.origin[1] * 0.125f; + pml.origin[2] = pm.s.origin[2] * 0.125f; - PMove.pml.velocity[0] = PMove.pm.s.velocity[0] * 0.125f; - PMove.pml.velocity[1] = PMove.pm.s.velocity[1] * 0.125f; - PMove.pml.velocity[2] = PMove.pm.s.velocity[2] * 0.125f; + pml.velocity[0] = pm.s.velocity[0] * 0.125f; + pml.velocity[1] = pm.s.velocity[1] * 0.125f; + pml.velocity[2] = pm.s.velocity[2] * 0.125f; // save old org in case we get stuck - Math3D.VectorCopy(PMove.pm.s.origin, PMove.pml.previous_origin); + Math3D.VectorCopy(pm.s.origin, pml.previous_origin); - PMove.pml.frametime = (PMove.pm.cmd.msec & 0xFF) * 0.001f; + pml.frametime = (pm.cmd.msec & 0xFF) * 0.001f; PM_ClampAngles(); - if (PMove.pm.s.pm_type == Defines.PM_SPECTATOR) { - PMove.PM_FlyMove(false); + if (pm.s.pm_type == Defines.PM_SPECTATOR) { + PM_FlyMove(false); PM_SnapPosition(); return; } - if (PMove.pm.s.pm_type >= Defines.PM_DEAD) { - PMove.pm.cmd.forwardmove = 0; - PMove.pm.cmd.sidemove = 0; - PMove.pm.cmd.upmove = 0; + if (pm.s.pm_type >= Defines.PM_DEAD) { + pm.cmd.forwardmove = 0; + pm.cmd.sidemove = 0; + pm.cmd.upmove = 0; } - if (PMove.pm.s.pm_type == Defines.PM_FREEZE) + if (pm.s.pm_type == Defines.PM_FREEZE) return; // no movement at all // set mins, maxs, and viewheight - PMove.PM_CheckDuck(); + PM_CheckDuck(); - if (PMove.pm.snapinitial) + if (pm.snapinitial) PM_InitialSnapPosition(); // set groundentity, watertype, and waterlevel - PMove.PM_CatagorizePosition(); + PM_CatagorizePosition(); - if (PMove.pm.s.pm_type == Defines.PM_DEAD) - PMove.PM_DeadMove(); + if (pm.s.pm_type == Defines.PM_DEAD) + PM_DeadMove(); - PMove.PM_CheckSpecialMovement(); + PM_CheckSpecialMovement(); // drop timing counter - if (PMove.pm.s.pm_time != 0) { + if (pm.s.pm_time != 0) { int msec; // TOD o bugfix cwei - msec = PMove.pm.cmd.msec >>> 3; + msec = pm.cmd.msec >>> 3; if (msec == 0) msec = 1; - if (msec >= (PMove.pm.s.pm_time & 0xFF)) { - PMove.pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP + if (msec >= (pm.s.pm_time & 0xFF)) { + pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT); - PMove.pm.s.pm_time = 0; + pm.s.pm_time = 0; } else - PMove.pm.s.pm_time = (byte) ((PMove.pm.s.pm_time & 0xFF) - msec); + pm.s.pm_time = (byte) ((pm.s.pm_time & 0xFF) - msec); } - if ((PMove.pm.s.pm_flags & pmove_t.PMF_TIME_TELEPORT) != 0) { // teleport - // pause - // stays - // exactly - // in - // place - } else if ((PMove.pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0) { // waterjump - // has - // no - // control, - // but - // falls - PMove.pml.velocity[2] -= PMove.pm.s.gravity * PMove.pml.frametime; - if (PMove.pml.velocity[2] < 0) { // cancel as soon as we are falling - // down again - PMove.pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP + if ((pm.s.pm_flags & pmove_t.PMF_TIME_TELEPORT) != 0) { + // teleport pause stays exaclty in place + } else if ((pm.s.pm_flags & pmove_t.PMF_TIME_WATERJUMP) != 0) { + // waterjump has no control, but falls + pml.velocity[2] -= pm.s.gravity * pml.frametime; + if (pml.velocity[2] < 0) { + // cancel as soon as we are falling down again + pm.s.pm_flags &= ~(pmove_t.PMF_TIME_WATERJUMP | pmove_t.PMF_TIME_LAND | pmove_t.PMF_TIME_TELEPORT); - PMove.pm.s.pm_time = 0; + pm.s.pm_time = 0; } - PMove.PM_StepSlideMove(); + PM_StepSlideMove(); } else { - PMove.PM_CheckJump(); + PM_CheckJump(); - PMove.PM_Friction(); + PM_Friction(); - if (PMove.pm.waterlevel >= 2) - PMove.PM_WaterMove(); + if (pm.waterlevel >= 2) + PM_WaterMove(); else { float[] angles = { 0, 0, 0 }; - Math3D.VectorCopy(PMove.pm.viewangles, angles); + Math3D.VectorCopy(pm.viewangles, angles); + if (angles[Defines.PITCH] > 180) angles[Defines.PITCH] = angles[Defines.PITCH] - 360; + angles[Defines.PITCH] /= 3; - Math3D.AngleVectors(angles, PMove.pml.forward, PMove.pml.right, - PMove.pml.up); + Math3D.AngleVectors(angles, pml.forward, pml.right, pml.up); - PMove.PM_AirMove(); + PM_AirMove(); } } // set groundentity, watertype, and waterlevel for final spot - PMove.PM_CatagorizePosition(); - + PM_CatagorizePosition(); PM_SnapPosition(); } }
\ No newline at end of file diff --git a/src/jake2/server/SV_ENTS.java b/src/jake2/server/SV_ENTS.java index 6f4ca0f..0f32322 100644 --- a/src/jake2/server/SV_ENTS.java +++ b/src/jake2/server/SV_ENTS.java @@ -19,7 +19,9 @@ */ // Created on 17.01.2004 by RST. -// $Id: SV_ENTS.java,v 1.6 2005-12-03 19:46:17 salomo Exp $ + +// $Id: SV_ENTS.java,v 1.7 2005-12-27 21:02:30 salomo Exp $ + package jake2.server; import jake2.Defines; @@ -31,7 +33,7 @@ import java.io.IOException; public class SV_ENTS { - /* + /** * ============================================================================= * * Build a client frame structure @@ -49,11 +51,8 @@ public class SV_ENTS { * ============================================================================= */ - /* - * ============= SV_EmitPacketEntities - * + /** * Writes a delta update of an entity_state_t list to the message. - * ============= */ static void SV_EmitPacketEntities(client_frame_t from, client_frame_t to, sizebuf_t msg) { @@ -89,11 +88,11 @@ public class SV_ENTS { oldnum = oldent.number; } - if (newnum == oldnum) { // delta update from old position + if (newnum == oldnum) { + // delta update from old position // because the force parm is false, this will not result // in any bytes being emited if the entity has not changed at - // all - // note that players are always 'newentities', this updates + // all note that players are always 'newentities', this updates // their oldorigin always // and prevents warping MSG.WriteDeltaEntity(oldent, newent, msg, false, @@ -103,16 +102,16 @@ public class SV_ENTS { continue; } - if (newnum < oldnum) { // this is a new entity, send it from the - // baseline + if (newnum < oldnum) { + // this is a new entity, send it from the baseline MSG.WriteDeltaEntity(SV_INIT.sv.baselines[newnum], newent, msg, true, true); newindex++; continue; } - if (newnum > oldnum) { // the old entity isn't present in the new - // message + if (newnum > oldnum) { + // the old entity isn't present in the new message bits = Defines.U_REMOVE; if (oldnum >= 256) bits |= Defines.U_NUMBER16 | Defines.U_MOREBITS1; @@ -135,10 +134,8 @@ public class SV_ENTS { } - /* - * ============= SV_WritePlayerstateToClient - * - * ============= + /** + * Writes the status of a player to a client system. */ static void SV_WritePlayerstateToClient(client_frame_t from, client_frame_t to, sizebuf_t msg) { @@ -158,9 +155,7 @@ public class SV_ENTS { } else ops = from.ps; - // // determine what needs to be sent - // pflags = 0; if (ps.pmove.pm_type != ops.pmove.pm_type) @@ -220,15 +215,11 @@ public class SV_ENTS { pflags |= Defines.PS_WEAPONINDEX; - // // write it - // MSG.WriteByte(msg, Defines.svc_playerinfo); MSG.WriteShort(msg, pflags); - // // write the pmove_state_t - // if ((pflags & Defines.PS_M_TYPE) != 0) MSG.WriteByte(msg, ps.pmove.pm_type); @@ -259,9 +250,7 @@ public class SV_ENTS { MSG.WriteShort(msg, ps.pmove.delta_angles[2]); } - // // write the rest of the player_state_t - // if ((pflags & Defines.PS_VIEWOFFSET) != 0) { MSG.WriteChar(msg, ps.viewoffset[0] * 4); MSG.WriteChar(msg, ps.viewoffset[1] * 4); @@ -316,8 +305,8 @@ public class SV_ENTS { MSG.WriteShort(msg, ps.stats[i]); } - /* - * ================== SV_WriteFrameToClient ================== + /** + * Writes a frame to a client system. */ public static void SV_WriteFrameToClient(client_t client, sizebuf_t msg) { //ptr @@ -359,8 +348,10 @@ public class SV_ENTS { SV_EmitPacketEntities(oldframe, frame, msg); } - /** The client will interpolate the view position, so we can't use a single - * PVS point. */ + /** + * The client will interpolate the view position, so we can't use a single + * PVS point. + */ public static void SV_FatPVS(float[] org) { int leafs[] = new int[64]; int i, j, count; @@ -472,7 +463,7 @@ public class SV_ENTS { continue; // ignore if not touching a PV leaf - // check area + // check area if (ent != clent) { if (!CM.CM_AreasConnected(clientarea, ent.areanum)) { // doors can legally straddle two areas, so we may need to check another one @@ -543,11 +534,9 @@ public class SV_ENTS { } } - /* - * ================== SV_RecordDemoMessage - * + /** * Save everything in the world out without deltas. Used for recording - * footage for merged or assembled demos ================== + * footage for merged or assembled demos. */ public static void SV_RecordDemoMessage() { int e; diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java index e9b876e..e325aef 100644 --- a/src/jake2/server/SV_MAIN.java +++ b/src/jake2/server/SV_MAIN.java @@ -19,7 +19,7 @@ */ // Created on 13.01.2004 by RST. -// $Id: SV_MAIN.java,v 1.14 2005-12-18 22:10:13 cawe Exp $ +// $Id: SV_MAIN.java,v 1.15 2005-12-27 21:02:30 salomo Exp $ package jake2.server; import jake2.Defines; @@ -34,10 +34,11 @@ import java.io.IOException; public class SV_MAIN { - public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS]; // address - // of - // group - // servers + /** Addess of group servers.*/ + public static netadr_t master_adr[] = new netadr_t[Defines.MAX_MASTERS]; + + + static { for (int i = 0; i < Defines.MAX_MASTERS; i++) { master_adr[i] = new netadr_t(); @@ -85,24 +86,16 @@ public class SV_MAIN { public static cvar_t sv_reconnect_limit; // minimum seconds between connect // messages - //============================================================================ - - /* - * ================ Master_Heartbeat - * + /** * Send a message to the master every few minutes to let it know we are - * alive, and log information ================ + * alive, and log information. */ public static final int HEARTBEAT_SECONDS = 300; - //============================================================================ - - /* - * ===================== SV_DropClient - * + /** * Called when the player is totally leaving the server, either willingly or * unwillingly. This is NOT called if the entire server is quiting or - * crashing. ===================== + * crashing. */ public static void SV_DropClient(client_t drop) { // add the disconnect @@ -123,19 +116,15 @@ public class SV_MAIN { drop.name = ""; } - /* - * ============================================================================== + + /* ============================================================================== * * CONNECTIONLESS COMMANDS * - * ============================================================================== - */ - - /* - * =============== SV_StatusString - * - * Builds the string that is sent as heartbeats and status replies - * =============== + * ==============================================================================*/ + + /** + * Builds the string that is sent as heartbeats and status replies. */ public static String SV_StatusString() { String player; @@ -167,31 +156,25 @@ public class SV_MAIN { return status; } - /* - * ================ SVC_Status - * - * Responds with all the info that qplug or qspy can see ================ + /** + * Responds with all the info that qplug or qspy can see */ public static void SVC_Status() { Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "print\n" + SV_StatusString()); } - /* - * ================ SVC_Ack - * - * ================ + /** + * SVC_Ack */ public static void SVC_Ack() { Com.Printf("Ping acknowledge from " + NET.AdrToString(Globals.net_from) + "\n"); } - /* - * ================ SVC_Info - * - * Responds with short info for broadcast scans The second parameter should - * be the current protocol version number. ================ + /** + * SVC_Info, responds with short info for broadcast scans The second parameter should + * be the current protocol version number. */ public static void SVC_Info() { String string; @@ -219,22 +202,18 @@ public class SV_MAIN { + string); } - /* - * ================ SVC_Ping - * - * Just responds with an acknowledgement ================ + /** + * SVC_Ping, Just responds with an acknowledgement. */ public static void SVC_Ping() { Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "ack"); } - /* - * ================= SVC_GetChallenge - * + /** * Returns a challenge number that can be used in a subsequent * client_connect command. We do this to prevent denial of service attacks * that flood the server with invalid connection IPs. With a challenge, they - * must give a valid IP address. ================= + * must give a valid IP address. */ public static void SVC_GetChallenge() { int i; @@ -268,10 +247,8 @@ public class SV_MAIN { "challenge " + SV_INIT.svs.challenges[i].challenge); } - /* - * ================== SVC_DirectConnect - * - * A connection request that did not come from the master ================== + /** + * A connection request that did not come from the master. */ public static void SVC_DirectConnect() { String userinfo; @@ -279,8 +256,6 @@ public class SV_MAIN { int i; client_t cl; - edict_t ent; - int edictnum; int version; int qport; @@ -300,11 +275,8 @@ public class SV_MAIN { int challenge = Lib.atoi(Cmd.Argv(3)); userinfo = Cmd.Argv(4); - //userinfo[sizeof(userinfo) - 1] = 0; - // force the IP key/value pair so the game can filter based on ip - userinfo = Info.Info_SetValueForKey1(userinfo, "ip", NET - .AdrToString(Globals.net_from)); + userinfo = Info.Info_SetValueForKey(userinfo, "ip", NET.AdrToString(Globals.net_from)); // attractloop servers are ONLY for local clients if (SV_INIT.sv.attractloop) { @@ -375,20 +347,26 @@ public class SV_MAIN { gotnewcl(index, challenge, userinfo, adr, qport); } + /** + * Initializes player structures after successfull connection. + */ public static void gotnewcl(int i, int challenge, String userinfo, netadr_t adr, int qport) { // build a new connection // accept the new client // this is the only place a client_t is ever initialized - //*newcl = temp; SV_MAIN.sv_client = SV_INIT.svs.clients[i]; - //edictnum = (newcl-svs.clients)+1; + int edictnum = i + 1; + edict_t ent = GameBase.g_edicts[edictnum]; SV_INIT.svs.clients[i].edict = ent; - SV_INIT.svs.clients[i].challenge = challenge; // save challenge for - // checksumming + + // save challenge for checksumming + SV_INIT.svs.clients[i].challenge = challenge; + + // get the game a chance to reject this connection or modify the // userinfo @@ -411,21 +389,24 @@ public class SV_MAIN { // send the connect packet to the client Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "client_connect"); - Netchan.Setup(Defines.NS_SERVER, SV_INIT.svs.clients[i].netchan, adr, - qport); + Netchan.Setup(Defines.NS_SERVER, SV_INIT.svs.clients[i].netchan, adr, qport); SV_INIT.svs.clients[i].state = Defines.cs_connected; SZ.Init(SV_INIT.svs.clients[i].datagram, SV_INIT.svs.clients[i].datagram_buf, SV_INIT.svs.clients[i].datagram_buf.length); + SV_INIT.svs.clients[i].datagram.allowoverflow = true; - SV_INIT.svs.clients[i].lastmessage = SV_INIT.svs.realtime; // don't - // timeout + SV_INIT.svs.clients[i].lastmessage = SV_INIT.svs.realtime; // don't timeout SV_INIT.svs.clients[i].lastconnect = SV_INIT.svs.realtime; Com.DPrintf("new client added.\n"); } + + /** + * Checks if the rcon password is corect. + */ public static int Rcon_Validate() { if (0 == SV_MAIN.rcon_password.string.length()) return 0; @@ -478,12 +459,10 @@ public class SV_MAIN { Com.EndRedirect(); } - /* - * ================= SV_ConnectionlessPacket - * + /** * A connectionless packet has four leading 0xff characters to distinguish * it from a game channel. Clients that are in the game can still send - * connectionless packets. ================= + * connectionless packets. It is used also by rcon commands. */ public static void SV_ConnectionlessPacket() { String s; @@ -497,8 +476,9 @@ public class SV_MAIN { Cmd.TokenizeString(s.toCharArray(), false); c = Cmd.Argv(0); - //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c - // + "\n"); + + //for debugging purposes + //Com.Printf("Packet " + NET.AdrToString(Netchan.net_from) + " : " + c + "\n"); //Com.Printf(Lib.hexDump(net_message.data, 64, false) + "\n"); if (0 == Lib.strcmp(c, "ping")) @@ -523,12 +503,8 @@ public class SV_MAIN { } } - //============================================================================ - - /* - * =================== SV_CalcPings - * - * Updates the cl.ping variables =================== + /** + * Updates the cl.ping variables. */ public static void SV_CalcPings() { int i, j; @@ -558,12 +534,9 @@ public class SV_MAIN { } } - /* - * =================== SV_GiveMsec - * + /** * Every few frames, gives all clients an allotment of milliseconds for * their command moves. If they exceed it, assume cheating. - * =================== */ public static void SV_GiveMsec() { int i; @@ -581,8 +554,8 @@ public class SV_MAIN { } } - /* - * ================= SV_ReadPackets ================= + /** + * Reads packets from the network or loopback. */ public static void SV_ReadPackets() { int i; @@ -638,16 +611,14 @@ public class SV_MAIN { } } - /* - * ================== SV_CheckTimeouts - * + /** * If a packet has not been received from a client for timeout.value * seconds, drop the conneciton. Server frames are used instead of realtime * to avoid dropping the local client while debugging. * * When a client is normally dropped, the client_t goes into a zombie state * for a few seconds to make sure any final reliable message gets resent if - * necessary ================== + * necessary. */ public static void SV_CheckTimeouts() { int i; @@ -678,11 +649,11 @@ public class SV_MAIN { } } - /* - * ================ SV_PrepWorldFrame + /** + * SV_PrepWorldFrame * * This has to be done before the world logic, because player processing - * happens outside RunWorldFrame ================ + * happens outside RunWorldFrame. */ public static void SV_PrepWorldFrame() { edict_t ent; @@ -696,8 +667,8 @@ public class SV_MAIN { } - /* - * ================= SV_RunGameFrame ================= + /** + * SV_RunGameFrame. */ public static void SV_RunGameFrame() { if (Globals.host_speeds.value != 0) @@ -727,10 +698,8 @@ public class SV_MAIN { } - /* - * ================== SV_Frame - * - * ================== + /** + * SV_Frame. */ public static void SV_Frame(long msec) { Globals.time_before_game = Globals.time_after_game = 0; @@ -767,11 +736,9 @@ public class SV_MAIN { } // update ping based on the last known frame from all clients - //TODO: dont need yet SV_CalcPings(); // give the clients some timeslices - //TODO: dont need yet SV_GiveMsec(); // let everything in the world think and move @@ -781,11 +748,9 @@ public class SV_MAIN { SV_SEND.SV_SendClientMessages(); // save the entire world state if recording a serverdemo - //TODO: dont need yet - //SV_WORLD.SV_RecordDemoMessage(); + SV_ENTS.SV_RecordDemoMessage(); // send a heartbeat to the master if needed - //TODO: dont need yet Master_Heartbeat(); // clear teleport flags, etc for next frame @@ -826,11 +791,10 @@ public class SV_MAIN { SV_MAIN.master_adr[i], "heartbeat\n" + string); } } + - /* - * ================= Master_Shutdown - * - * Informs all masters that this server is going down ================= + /** + * Master_Shutdown, Informs all masters that this server is going down. */ public static void Master_Shutdown() { int i; @@ -853,14 +817,11 @@ public class SV_MAIN { SV_MAIN.master_adr[i], "shutdown"); } } + - //============================================================================ - - /* - * ================= SV_UserinfoChanged - * + /** * Pull specific info from a newly changed userinfo string into a more C - * freindly form. ================= + * freindly form. */ public static void SV_UserinfoChanged(client_t cl) { String val; @@ -897,11 +858,7 @@ public class SV_MAIN { } - //============================================================================ - - /* - * =============== SV_Init - * + /** * Only called at quake2.exe startup, not for each game =============== */ public static void SV_Init() { @@ -952,13 +909,11 @@ public class SV_MAIN { Globals.net_message_buffer.length); } - /* - * ================== SV_FinalMessage - * + /** * Used by SV_Shutdown to send a final message to all connected clients * before the server goes down. The messages are sent immediately, not just * stuck on the outgoing message list, because the server is going to - * totally exit after returning from this function. ================== + * totally exit after returning from this function. */ public static void SV_FinalMessage(String message, boolean reconnect) { int i; @@ -991,11 +946,8 @@ public class SV_MAIN { } } - /* - * ================ SV_Shutdown - * - * Called when each game quits, before Sys_Quit or Sys_Error - * ================ + /** + * Called when each game quits, before Sys_Quit or Sys_Error. */ public static void SV_Shutdown(String finalmsg, boolean reconnect) { if (SV_INIT.svs.clients != null) diff --git a/src/jake2/sys/NET.java b/src/jake2/sys/NET.java index 702447d..d13c324 100644 --- a/src/jake2/sys/NET.java +++ b/src/jake2/sys/NET.java @@ -1,7 +1,7 @@ /* * NET.java Copyright (C) 2003 * - * $Id: NET.java,v 1.8 2005-06-26 09:17:33 hzi Exp $ + * $Id: NET.java,v 1.9 2005-12-27 21:02:31 salomo Exp $ */ /* * Copyright (C) 1997-2001 Id Software, Inc. @@ -45,7 +45,7 @@ public final class NET { private final static int MAX_LOOPBACK = 4; - // local loopback adress + /** Local loopback adress. */ private static netadr_t net_local_adr = new netadr_t(); public static class loopmsg_t { @@ -77,20 +77,16 @@ public final class NET { private static DatagramSocket[] ip_sockets = { null, null }; - /* - * CompareAdr - * - * Compares with the port + /** + * Compares ip address and port. */ public static boolean CompareAdr(netadr_t a, netadr_t b) { return (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3] && a.port == b.port); } - /* - * CompareBaseAdr - * - * Compares without the port + /** + * Compares ip address without the port. */ public static boolean CompareBaseAdr(netadr_t a, netadr_t b) { if (a.type != b.type) @@ -106,10 +102,8 @@ public final class NET { return false; } - /* - * AdrToString - * - * IP address with the port + /** + * Returns a string holding ip address and port like "ip0.ip1.ip2.ip3:port". */ public static String AdrToString(netadr_t a) { StringBuffer sb = new StringBuffer(); @@ -120,10 +114,8 @@ public final class NET { return sb.toString(); } - /* - * BaseAdrToString - * - * IP address without the port + /** + * Returns IP address without the port as string. */ public static String BaseAdrToString(netadr_t a) { StringBuffer sb = new StringBuffer(); @@ -133,8 +125,8 @@ public final class NET { return sb.toString(); } - /* - * StringToAdr + /** + * Creates an netadr_t from an string. */ public static boolean StringToAdr(String s, netadr_t a) { if (s.equalsIgnoreCase("localhost") || s.equalsIgnoreCase("loopback")) { @@ -155,8 +147,8 @@ public final class NET { } } - /* - * IsLocalAddress + /** + * Seems to return true, if the address is is on 127.0.0.1. */ public static boolean IsLocalAddress(netadr_t adr) { return CompareAdr(adr, net_local_adr); @@ -170,6 +162,9 @@ public final class NET { * ================================================== */ + /** + * Gets a packet from internal loopback. + */ public static boolean GetLoopPacket(int sock, netadr_t net_from, sizebuf_t net_message) { loopback_t loop; @@ -192,8 +187,8 @@ public final class NET { return true; } - /* - * SendLoopPacket + /** + * Sends a packet via internal loopback. */ public static void SendLoopPacket(int sock, int length, byte[] data, netadr_t to) { @@ -210,8 +205,8 @@ public final class NET { loop.msgs[i].datalen = length; } - /* - * GetPacket + /** + * Gets a packet from a network channel */ public static boolean GetPacket(int sock, netadr_t net_from, sizebuf_t net_message) { @@ -255,8 +250,8 @@ public final class NET { } } - /* - * SendPacket + /** + * Sends a Packet. */ public static void SendPacket(int sock, int length, byte[] data, netadr_t to) { if (to.type == Defines.NA_LOOPBACK) { @@ -273,18 +268,15 @@ public final class NET { } try { - SocketAddress dstSocket = new InetSocketAddress( - to.getInetAddress(), to.port); + SocketAddress dstSocket = new InetSocketAddress(to.getInetAddress(), to.port); ip_channels[sock].send(ByteBuffer.wrap(data, 0, length), dstSocket); } catch (Exception e) { - Com - .Println("NET_SendPacket ERROR: " + e + " to " - + AdrToString(to)); + Com.Println("NET_SendPacket ERROR: " + e + " to " + AdrToString(to)); } } - /* - * OpenIP + /** + * OpenIP, creates the network sockets. */ public static void OpenIP() { cvar_t port, ip; @@ -301,10 +293,8 @@ public final class NET { ip.string, Defines.PORT_ANY); } - /* - * Config - * - * A single player game will only use the loopback code + /** + * Config multi or singlepalyer - A single player game will only use the loopback code. */ public static void Config(boolean multiplayer) { if (!multiplayer) { @@ -321,7 +311,7 @@ public final class NET { } } - /* + /** * Init */ public static void Init() { @@ -363,15 +353,15 @@ public final class NET { return newsocket; } - /* - * Shutdown + /** + * Shutdown - closes the sockets */ public static void Shutdown() { // close sockets Config(false); } - // sleeps msec or until net socket is ready + /** Sleeps msec or until net socket is ready. */ public static void Sleep(int msec) { if (ip_sockets[Defines.NS_SERVER] == null || (Globals.dedicated != null && Globals.dedicated.value == 0)) @@ -386,17 +376,25 @@ public final class NET { // this should wait up to 100ms until a packet /* - * struct timeval timeout; fd_set fdset; extern cvar_t *dedicated; + * struct timeval timeout; + * fd_set fdset; + * extern cvar_t *dedicated; * extern qboolean stdin_active; * * if (!ip_sockets[NS_SERVER] || (dedicated && !dedicated.value)) - * return; // we're not a server, just run full speed + * return; // we're not a server, just run full speed + * + * FD_ZERO(&fdset); + * + * if (stdin_active) + * FD_SET(0, &fdset); // stdin is processed too + * + * FD_SET(ip_sockets[NS_SERVER], &fdset); // network socket + * + * timeout.tv_sec = msec/1000; + * timeout.tv_usec = (msec%1000)*1000; * - * FD_ZERO(&fdset); if (stdin_active) FD_SET(0, &fdset); // stdin is - * processed too FD_SET(ip_sockets[NS_SERVER], &fdset); // network - * socket timeout.tv_sec = msec/1000; timeout.tv_usec = - * (msec%1000)*1000; select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, - * &timeout); + * select(ip_sockets[NS_SERVER]+1, &fdset, NULL, NULL, &timeout); */ } }
\ No newline at end of file diff --git a/test/jake2/qcommon/TestINFO.java b/test/jake2/qcommon/TestINFO.java index 6a8483a..1074513 100644 --- a/test/jake2/qcommon/TestINFO.java +++ b/test/jake2/qcommon/TestINFO.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 29.12.2003 by RST. -// $Id: TestINFO.java,v 1.2 2004-09-22 19:22:10 salomo Exp $ +// $Id: TestINFO.java,v 1.3 2005-12-27 21:02:30 salomo Exp $ package jake2.qcommon; @@ -34,7 +34,7 @@ public class TestINFO { public static void main(String args[]) { String test = "\\key1\\value 1\\key 2 \\value2\\key3\\ v a l u e 3\\key4\\val ue 4"; Info.Print(test); - test = Info.Info_RemoveKey1(test, "key1"); + test = Info.Info_RemoveKey(test, "key1"); Info.Print(test); } } |