From e818226c349b8a357b1706263997d27506d4e702 Mon Sep 17 00:00:00 2001 From: Joseph Carter Date: Sat, 11 Mar 2000 21:29:48 +0000 Subject: [PATCH] This SHOULD allow Mega2K to work whenever it gets released. View offsets are done (sorry if this steps on your toes with the view.c merge Deek) and I'm almost positive flymode will now work. Even though view offset is done, it won't. The reason for this is that cl.stats[STAT_FLYMODE] is pretty much going to ALWAYS be 0 on a standard server. Since 0 tells us that we're not flying, this is fine. cl.stats[STAT_VIEWHEIGHT] is also going to be 0, but it should be 22 for normal views. I could always assume this value is an offset from 22, but that just seems lame to me. I'll either do it anyway or we'll have to find a good opportunity in the connect cycle to set the cl.qfserver qboolean to true. I'm thinking about using an info key value for this, but we'd be better served I think by coordinating with QSG to up the protocol version across all engines. --- common/bothdefs.h | 3 +- common/client.h | 1 + common/pmove.h | 10 ++-- qw_client/cl_pred.c | 95 +++++++++++++++++----------------- qw_client/view.c | 122 +++++++++++++++----------------------------- qw_server/sv_send.c | 6 ++- uquake/view.c | 2 +- 7 files changed, 104 insertions(+), 135 deletions(-) diff --git a/common/bothdefs.h b/common/bothdefs.h index 6981f14..47f4221 100644 --- a/common/bothdefs.h +++ b/common/bothdefs.h @@ -98,8 +98,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define STAT_TOTALMONSTERS 12 #define STAT_SECRETS 13 // bumped on client side by svc_foundsecret #define STAT_MONSTERS 14 // bumped by svc_killedmonster -#define STAT_ITEMS 15 +#define STAT_ITEMS 15 #define STAT_VIEWHEIGHT 16 +#define STAT_FLYMODE 17 // diff --git a/common/client.h b/common/client.h index bdd2eb1..a50d929 100644 --- a/common/client.h +++ b/common/client.h @@ -293,6 +293,7 @@ typedef struct // QW specific! // all player information + qboolean qfserver; player_info_t players[MAX_CLIENTS]; int servercount; // server identification for prespawns diff --git a/common/pmove.h b/common/pmove.h index 59a73cd..917a317 100644 --- a/common/pmove.h +++ b/common/pmove.h @@ -1,4 +1,5 @@ /* +pmove.h Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1999,2000 contributors of the QuakeForge project Please see the file "AUTHORS" for a list of contributors @@ -23,10 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __PMOVE_H #define __PMOVE_H -#include "pmove_simple.h" -#include "model.h" -#include "net.h" -#include "protocol.h" +#include +#include +#include +#include typedef struct { @@ -48,6 +49,7 @@ typedef struct int oldbuttons; float waterjumptime; qboolean dead; + qboolean flying; int spectator; // world state diff --git a/qw_client/cl_pred.c b/qw_client/cl_pred.c index 619f541..5b06acb 100644 --- a/qw_client/cl_pred.c +++ b/qw_client/cl_pred.c @@ -1,4 +1,5 @@ /* +cl_pred.c Copyright (C) 1996-1997 Id Software, Inc. Portions Copyright (C) 1999,2000 Nelson Rush. Copyright (C) 1999,2000 contributors of the QuakeForge project @@ -20,36 +21,34 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "qtypes.h" -#include "quakedef.h" -#include "winquake.h" -#include "cvar.h" -#include "client.h" -#include "console.h" -#include "mathlib.h" +#include +#include +#include +#include +#include +#include +#include -//cvar_t cl_nopred = {"cl_nopred","0"}; cvar_t *cl_nopred; -//cvar_t cl_pushlatency = {"pushlatency","-999"}; cvar_t *cl_pushlatency; extern frame_t *view_frame; /* -================= -CL_NudgePosition + CL_NudgePosition -If pmove.origin is in a solid position, -try nudging slightly on all axis to -allow for the cut precision of the net coordinates -================= + If pmove.origin is in a solid position, + try nudging slightly on all axis to + allow for the cut precision of the net coordinates */ -void CL_NudgePosition (void) +void +CL_NudgePosition (void) { vec3_t base; int x, y; - if (PM_HullPointContents (&cl.model_precache[1]->hulls[1], 0, pmove.origin) == CONTENTS_EMPTY) + if (PM_HullPointContents (&cl.model_precache[1]->hulls[1], 0, + pmove.origin) == CONTENTS_EMPTY) return; VectorCopy (pmove.origin, base); @@ -66,12 +65,13 @@ void CL_NudgePosition (void) Con_DPrintf ("CL_NudgePosition: stuck\n"); } + /* -============== -CL_PredictUsercmd -============== + CL_PredictUsercmd */ -void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, qboolean spectator) +void +CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, + qboolean spectator) { // split up very long moves if (u->msec > 50) @@ -97,6 +97,7 @@ void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, pmove.dead = cl.stats[STAT_HEALTH] <= 0; pmove.spectator = spectator; + pmove.flying = cl.stats[STAT_FLYMODE]; pmove.cmd = *u; PlayerMove (); @@ -115,11 +116,10 @@ void CL_PredictUsercmd (player_state_t *from, player_state_t *to, usercmd_t *u, /* -============== -CL_PredictMove -============== + CL_PredictMove */ -void CL_PredictMove (void) +void +CL_PredictMove (void) { int i; float f; @@ -178,9 +178,11 @@ void CL_PredictMove (void) for (i=1 ; iplayerstate[cl.playernum] - , &to->playerstate[cl.playernum], &to->cmd, cl.spectator); + to = &cl.frames[(cls.netchan.incoming_sequence+i) + & UPDATE_MASK]; + CL_PredictUsercmd (&from->playerstate[cl.playernum], + &to->playerstate[cl.playernum], &to->cmd, + cl.spectator); if (to->senttime >= cl.time) break; from = to; @@ -196,42 +198,43 @@ void CL_PredictMove (void) f = 0; else { - f = (cl.time - from->senttime) / (to->senttime - from->senttime); + f = (cl.time - from->senttime) / (to->senttime + - from->senttime); - if (f < 0) - f = 0; - if (f > 1) - f = 1; + f = max(0, min(f, 1)); } for (i=0 ; i<3 ; i++) - if ( fabs(from->playerstate[cl.playernum].origin[i] - to->playerstate[cl.playernum].origin[i]) > 128) + if ( fabs(from->playerstate[cl.playernum].origin[i] + - to->playerstate[cl.playernum].origin[i]) + > 128) { // teleported, so don't lerp - VectorCopy (to->playerstate[cl.playernum].velocity, cl.simvel); - VectorCopy (to->playerstate[cl.playernum].origin, cl.simorg); + VectorCopy (to->playerstate[cl.playernum].velocity, + cl.simvel); + VectorCopy (to->playerstate[cl.playernum].origin, + cl.simorg); return; } for (i=0 ; i<3 ; i++) { cl.simorg[i] = from->playerstate[cl.playernum].origin[i] - + f*(to->playerstate[cl.playernum].origin[i] - from->playerstate[cl.playernum].origin[i]); + + f*(to->playerstate[cl.playernum].origin[i] + - from->playerstate[cl.playernum].origin[i]); cl.simvel[i] = from->playerstate[cl.playernum].velocity[i] - + f*(to->playerstate[cl.playernum].velocity[i] - from->playerstate[cl.playernum].velocity[i]); + + f*(to->playerstate[cl.playernum].velocity[i] + - from->playerstate[cl.playernum].velocity[i]); } } /* -============== -CL_InitPrediction -============== + CL_InitPrediction */ -void CL_InitPrediction (void) +void +CL_InitPrediction (void) { -// Cvar_RegisterVariable (&cl_pushlatency); - cl_pushlatency = Cvar_Get ("cl_pushlatency","0",0,"None"); -// Cvar_RegisterVariable (&cl_nopred); - cl_nopred = Cvar_Get ("cl_nopred","0",0,"None"); + cl_pushlatency = Cvar_Get ("cl_pushlatency","0",CVAR_NONE,"None"); + cl_nopred = Cvar_Get ("cl_nopred","0",CVAR_NONE,"None"); } diff --git a/qw_client/view.c b/qw_client/view.c index cce5556..ff6cd82 100644 --- a/qw_client/view.c +++ b/qw_client/view.c @@ -80,10 +80,7 @@ frame_t *view_frame; player_state_t *view_message; /* -=============== -V_CalcRoll - -=============== + V_CalcRoll */ float V_CalcRoll (vec3_t angles, vec3_t velocity) { @@ -110,10 +107,7 @@ float V_CalcRoll (vec3_t angles, vec3_t velocity) /* -=============== -V_CalcBob - -=============== + V_CalcBob */ float V_CalcBob (void) { @@ -180,17 +174,17 @@ void V_StopPitchDrift (void) } /* -=============== -V_DriftPitch + V_DriftPitch -Moves the client pitch angle towards cl.idealpitch sent by the server. + Moves the client pitch angle towards cl.idealpitch sent by the + server. -If the user is adjusting pitch manually, either with lookup/lookdown, -mlook and mouse, or klook and keyboard, pitch drifting is constantly stopped. + If the user is adjusting pitch manually, either with lookup/lookdown, + mlook and mouse, or klook and keyboard, pitch drifting is constantly + stopped. -Drifting is enabled when the center view key is hit, mlook is released and -lookspring is non 0, or when -=============== + Drifting is enabled when the center view key is hit, mlook is + released and lookspring is non 0, or when */ void V_DriftPitch (void) { @@ -257,9 +251,7 @@ void V_DriftPitch (void) /* ============================================================================== - - PALETTE FLASHES - + PALETTE FLASHES ============================================================================== */ @@ -300,9 +292,7 @@ void BuildGammaTable (float g) } /* -================= -V_CheckGamma -================= + V_CheckGamma */ qboolean V_CheckGamma (void) { @@ -321,9 +311,7 @@ qboolean V_CheckGamma (void) /* -=============== -V_ParseDamage -=============== + V_ParseDamage */ void V_ParseDamage (void) { @@ -389,9 +377,7 @@ void V_ParseDamage (void) /* -================== -V_cshift_f -================== + V_cshift_f */ void V_cshift_f (void) { @@ -403,11 +389,9 @@ void V_cshift_f (void) /* -================== -V_BonusFlash_f + V_BonusFlash_f -When you run over an item, the server sends this command -================== + When you run over an item, the server sends this command */ void V_BonusFlash_f (void) { @@ -418,11 +402,9 @@ void V_BonusFlash_f (void) } /* -============= -V_SetContentsColor + V_SetContentsColor -Underwater, lava, etc each has a color shift -============= + Underwater, lava, etc each has a color shift */ void V_SetContentsColor (int contents) { @@ -449,9 +431,7 @@ void V_SetContentsColor (int contents) } /* -============= -V_CalcPowerupCshift -============= + V_CalcPowerupCshift */ void V_CalcPowerupCshift (void) { @@ -489,9 +469,7 @@ void V_CalcPowerupCshift (void) /* -============= -V_CalcBlend -============= + V_CalcBlend */ void V_CalcBlend (void) { @@ -533,9 +511,7 @@ void V_CalcBlend (void) /* ============================================================================== - - VIEW RENDERING - + VIEW RENDERING ============================================================================== */ @@ -548,9 +524,7 @@ float angledelta (float a) } /* -================== -CalcGunAngle -================== + CalcGunAngle */ void CalcGunAngle (void) { @@ -602,9 +576,7 @@ void CalcGunAngle (void) } /* -============== -V_BoundOffsets -============== + V_BoundOffsets */ void V_BoundOffsets (void) { @@ -626,11 +598,9 @@ void V_BoundOffsets (void) } /* -============== -V_AddIdle + V_AddIdle -Idle swaying -============== + Idle swaying */ void V_AddIdle (void) { @@ -645,11 +615,9 @@ void V_AddIdle (void) /* -============== -V_CalcViewRoll + V_CalcViewRoll -Roll is induced by movement and damage -============== + Roll is induced by movement and damage */ void V_CalcViewRoll (void) { @@ -669,10 +637,7 @@ void V_CalcViewRoll (void) /* -================== -V_CalcIntermissionRefdef - -================== + V_CalcIntermissionRefdef */ void V_CalcIntermissionRefdef (void) { @@ -694,19 +659,18 @@ void V_CalcIntermissionRefdef (void) } /* -================== -V_CalcRefdef - -================== + V_CalcRefdef */ void V_CalcRefdef (void) { entity_t *view; - int i; + int h, i; vec3_t forward, right, up; float bob; static float oldz = 0; + h = cl.qfserver ? cl.stats[STAT_VIEWHEIGHT] : 22; + V_DriftPitch (); // view is the weapon model (only visible from inside body) @@ -735,9 +699,9 @@ void V_CalcRefdef (void) else if (view_message->flags & PF_DEAD) r_refdef.vieworg[2] -= 16; // corpse view height else - r_refdef.vieworg[2] += 22; // view height + r_refdef.vieworg[2] += h; // view height - if (view_message->flags & PF_DEAD) // PF_GIB will also set PF_DEAD + if (view_message->flags & PF_DEAD) // PF_GIB also sets PF_DEAD r_refdef.viewangles[ROLL] = 80; // dead view angle @@ -750,7 +714,7 @@ void V_CalcRefdef (void) CalcGunAngle (); VectorCopy (cl.simorg, view->origin); - view->origin[2] += 22; + view->origin[2] += h; for (i=0 ; i<3 ; i++) { @@ -801,9 +765,7 @@ void V_CalcRefdef (void) } /* -============= -DropPunchAngle -============= + DropPunchAngle */ void DropPunchAngle (void) { @@ -813,12 +775,10 @@ void DropPunchAngle (void) } /* -================== -V_RenderView + V_RenderView -The player's clipping box goes from (-16 -16 -24) to (16 16 32) from -the entity origin, so any view position inside that will be valid -================== + The player's clipping box goes from (-16 -16 -24) to (16 16 32) from + the entity origin, so any view position inside that will be valid */ extern vrect_t scr_vrect; @@ -854,9 +814,7 @@ cl.simangles[ROLL] = 0; // FIXME @@@ //============================================================================ /* -============= -V_Init -============= + V_Init */ void V_Init (void) { diff --git a/qw_server/sv_send.c b/qw_server/sv_send.c index 2b5fed5..1715cd3 100644 --- a/qw_server/sv_send.c +++ b/qw_server/sv_send.c @@ -1,4 +1,5 @@ /* +sv_send.c Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1999,2000 contributors of the QuakeForge project Please see the file "AUTHORS" for a list of contributors @@ -19,7 +20,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// sv_main.c -- server main program #include #include @@ -555,6 +555,10 @@ void SV_UpdateClientStats (client_t *client) // stuff the sigil bits into the high bits of items for sbar stats[STAT_ITEMS] = (int)ent->v.items | ((int)pr_global_struct->serverflags << 28); + // Extensions to the QW 2.40 protocol for MegaTF + stats[STAT_VIEWHEIGHT] = (int)ent->v.view_ofs[2]; + stats[STAT_FLYMODE] = (ent->v.movetype == MOVETYPE_FLY); + for (i=0 ; istats[i]) { diff --git a/uquake/view.c b/uquake/view.c index d5492f1..0f3a7cc 100644 --- a/uquake/view.c +++ b/uquake/view.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include /* For Draw_Crosshair() */ +#include #include #include #include