diff options
Diffstat (limited to 'src/jake2/client/CL_pred.java')
-rw-r--r-- | src/jake2/client/CL_pred.java | 155 |
1 files changed, 49 insertions, 106 deletions
diff --git a/src/jake2/client/CL_pred.java b/src/jake2/client/CL_pred.java index cc8061f..eecf0eb 100644 --- a/src/jake2/client/CL_pred.java +++ b/src/jake2/client/CL_pred.java @@ -2,7 +2,7 @@ * CL_pred.java * Copyright (C) 2004 * - * $Id: CL_pred.java,v 1.1 2004-07-07 19:58:39 hzi Exp $ + * $Id: CL_pred.java,v 1.2 2004-07-08 15:58:42 hzi Exp $ */ /* Copyright (C) 1997-2001 Id Software, Inc. @@ -31,23 +31,20 @@ import jake2.qcommon.*; /** * CL_pred */ -public class CL_pred extends CL_parse -{ +public class CL_pred extends CL_parse { /* =================== CL_CheckPredictionError =================== */ - static void CheckPredictionError() - { + static void CheckPredictionError() { int frame; int[] delta = new int[3]; int i; int len; - if (cl_predict.value == 0.0f - || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) + if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) return; // calculate the last usercmd_t we sent that the server has processed @@ -55,31 +52,19 @@ public class CL_pred extends CL_parse frame &= (CMD_BACKUP - 1); // compare what the server returned with what we had predicted it to be - VectorSubtract( - cl.frame.playerstate.pmove.origin, - cl.predicted_origins[frame], - delta); + VectorSubtract(cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame], delta); // save the prediction error for interpolation len = Math.abs(delta[0]) + Math.abs(delta[1]) + Math.abs(delta[2]); if (len > 640) // 80 world units - { // a teleport or something + { // a teleport or something VectorClear(cl.prediction_error); } - else - { - if (cl_showmiss.value != 0.0f - && (delta[0] != 0 || delta[1] != 0 || delta[2] != 0)) - Com.Printf( - "prediction miss on " - + cl.frame.serverframe - + ": " - + (delta[0] + delta[1] + delta[2]) - + "\n"); - - VectorCopy( - cl.frame.playerstate.pmove.origin, - cl.predicted_origins[frame]); + else { + if (cl_showmiss.value != 0.0f && (delta[0] != 0 || delta[1] != 0 || delta[2] != 0)) + Com.Printf("prediction miss on " + cl.frame.serverframe + ": " + (delta[0] + delta[1] + delta[2]) + "\n"); + + VectorCopy(cl.frame.playerstate.pmove.origin, cl.predicted_origins[frame]); // save for error itnerpolation for (i = 0; i < 3; i++) @@ -93,13 +78,7 @@ public class CL_pred extends CL_parse ==================== */ - static void ClipMoveToEntities( - float[] start, - float[] mins, - float[] maxs, - float[] end, - trace_t tr) - { + static void ClipMoveToEntities(float[] start, float[] mins, float[] maxs, float[] end, trace_t tr) { int i, x, zd, zu; trace_t trace; int headnode; @@ -110,8 +89,7 @@ public class CL_pred extends CL_parse float[] bmins = new float[3]; float[] bmaxs = new float[3]; - for (i = 0; i < cl.frame.num_entities; i++) - { + for (i = 0; i < cl.frame.num_entities; i++) { num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1); ent = cl_parse_entities[num]; @@ -121,16 +99,14 @@ public class CL_pred extends CL_parse if (ent.number == cl.playernum + 1) continue; - if (ent.solid == 31) - { // special value for bmodel + if (ent.solid == 31) { // special value for bmodel cmodel = cl.model_clip[ent.modelindex]; if (cmodel == null) continue; headnode = cmodel.headnode; angles = ent.angles; } - else - { // encoded bbox + else { // encoded bbox x = 8 * (ent.solid & 31); zd = 8 * ((ent.solid >>> 5) & 31); zu = 8 * ((ent.solid >>> 10) & 63) - 32; @@ -147,31 +123,16 @@ public class CL_pred extends CL_parse if (tr.allsolid) return; - trace = - CM.TransformedBoxTrace( - start, - end, - mins, - maxs, - headnode, - MASK_PLAYERSOLID, - ent.origin, - angles); - - if (trace.allsolid - || trace.startsolid - || trace.fraction < tr.fraction) - { - // TODO bugfix cwei - //if (trace.ent == null) trace.ent = new edict_t(0); + trace = CM.TransformedBoxTrace(start, end, mins, maxs, headnode, MASK_PLAYERSOLID, ent.origin, angles); + + if (trace.allsolid || trace.startsolid || trace.fraction < tr.fraction) { trace.ent = ent.surrounding_ent; - if (tr.startsolid) - { - tr = trace; + if (tr.startsolid) { + tr.set(trace); // rst: solved the Z U P P E L - P R O B L E M tr.startsolid = true; } else - tr = trace; + tr.set(trace); // rst: solved the Z U P P E L - P R O B L E M } else if (trace.startsolid) tr.startsolid = true; @@ -183,9 +144,9 @@ public class CL_pred extends CL_parse CL_PMTrace ================ */ - - static edict_t DUMMY_ENT = new edict_t(-1); - + + public static edict_t DUMMY_ENT = new edict_t(-1); + static trace_t PMTrace(float[] start, float[] mins, float[] maxs, float[] end) { trace_t t; @@ -202,8 +163,14 @@ public class CL_pred extends CL_parse return t; } - static int PMpointcontents(float[] point) - { + /* + ================= + PMpointcontents + + Returns the content identificator of the point. + ================= + */ + static int PMpointcontents(float[] point) { int i; entity_state_t ent; int num; @@ -212,8 +179,7 @@ public class CL_pred extends CL_parse contents = CM.PointContents(point, 0); - for (i = 0; i < cl.frame.num_entities; i++) - { + for (i = 0; i < cl.frame.num_entities; i++) { num = (cl.frame.parse_entities + i) & (MAX_PARSE_ENTITIES - 1); ent = cl_parse_entities[num]; @@ -224,14 +190,8 @@ public class CL_pred extends CL_parse if (cmodel == null) continue; - contents - |= CM.TransformedPointContents( - point, - cmodel.headnode, - ent.origin, - ent.angles); + contents |= CM.TransformedPointContents(point, cmodel.headnode, ent.origin, ent.angles); } - return contents; } @@ -242,8 +202,7 @@ public class CL_pred extends CL_parse Sets cl.predicted_origin and cl.predicted_angles ================= */ - static void PredictMovement() - { + static void PredictMovement() { int ack, current; int frame; int oldframe; @@ -259,14 +218,10 @@ public class CL_pred extends CL_parse if (cl_paused.value != 0.0f) return; - if (cl_predict.value == 0.0f - || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) - { // just set angles - for (i = 0; i < 3; i++) - { - cl.predicted_angles[i] = - cl.viewangles[i] - + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]); + if (cl_predict.value == 0.0f || (cl.frame.playerstate.pmove.pm_flags & PMF_NO_PREDICTION) != 0) { + // just set angles + for (i = 0; i < 3; i++) { + cl.predicted_angles[i] = cl.viewangles[i] + SHORT2ANGLE(cl.frame.playerstate.pmove.delta_angles[i]); } return; } @@ -275,8 +230,7 @@ public class CL_pred extends CL_parse current = cls.netchan.outgoing_sequence; // if we are too far out of date, just freeze - if (current - ack >= CMD_BACKUP) - { + if (current - ack >= CMD_BACKUP) { if (cl_showmiss.value != 0.0f) Com.Printf("exceeded CMD_BACKUP\n"); return; @@ -286,41 +240,32 @@ public class CL_pred extends CL_parse //memset (pm, 0, sizeof(pm)); pm = new pmove_t(); - pm.trace = new pmove_t.TraceAdapter() - { - public trace_t trace( - float[] start, - float[] mins, - float[] maxs, - float[] end) - { + pm.trace = new pmove_t.TraceAdapter() { + public trace_t trace(float[] start, float[] mins, float[] maxs, float[] end) { return CL.PMTrace(start, mins, maxs, end); } }; - pm.pointcontents = new pmove_t.PointContentsAdapter() - { - public int pointcontents(float[] point) - { + pm.pointcontents = new pmove_t.PointContentsAdapter() { + public int pointcontents(float[] point) { return CL.PMpointcontents(point); } }; PMove.pm_airaccelerate = atof(cl.configstrings[CS_AIRACCEL]); - // bugfix (rst) yeah !!!!!!!! found the B E W E G U N G S P R O B L E M. + // bugfix (rst) yeah !!!!!!!! found the solution to the B E W E G U N G S P R O B L E M. pm.s.set(cl.frame.playerstate.pmove); // SCR_DebugGraph (current - ack - 1, 0); frame = 0; // run frames - while (++ack < current) - { + while (++ack < current) { frame = ack & (CMD_BACKUP - 1); cmd = cl.cmds[frame]; - + pm.cmd.set(cmd); - + PMove.Pmove(pm); // save for debug checking @@ -330,8 +275,7 @@ public class CL_pred extends CL_parse oldframe = (ack - 2) & (CMD_BACKUP - 1); oldz = cl.predicted_origins[oldframe][2]; step = pm.s.origin[2] - oldz; - if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0) - { + if (step > 63 && step < 160 && (pm.s.pm_flags & PMF_ON_GROUND) != 0) { cl.predicted_step = step * 0.125f; cl.predicted_step_time = (int) (cls.realtime - cls.frametime * 500); } @@ -343,5 +287,4 @@ public class CL_pred extends CL_parse VectorCopy(pm.viewangles, cl.predicted_angles); } - } |