fix movetypes, fix q2.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3994 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2012-02-15 13:53:30 +00:00
parent 0736882c60
commit 47ccd3bd0d
13 changed files with 102 additions and 47 deletions

View File

@ -3390,6 +3390,8 @@ void CL_ParsePlayerinfo (void)
state->pm_type = PM_NONE; state->pm_type = PM_NONE;
else if (pm_code == PMC_FREEZE) else if (pm_code == PMC_FREEZE)
state->pm_type = PM_FREEZE; state->pm_type = PM_FREEZE;
else if (pm_code == PMC_WALLWALK)
state->pm_type = PM_WALLWALK;
else { else {
// future extension? // future extension?
goto guess_pm_type; goto guess_pm_type;

View File

@ -606,11 +606,14 @@ void CL_ClampPitch (int pnum)
vec3_t view[4]; vec3_t view[4];
vec3_t impact, norm; vec3_t impact, norm;
float mat[16], mat2[16]; float mat[16], mat2[16];
vec3_t cross;
float roll;
float dot;
static float oldtime; static float oldtime;
float timestep = realtime - oldtime; float timestep = realtime - oldtime;
oldtime = realtime; oldtime = realtime;
if (1) if (cl.pmovetype[pnum] == PM_WALLWALK)
{ {
AngleVectors(cl.viewangles[pnum], view[0], view[1], view[2]); AngleVectors(cl.viewangles[pnum], view[0], view[1], view[2]);
Matrix4x4_RM_FromVectors(mat, view[0], view[1], view[2], vec3_origin); Matrix4x4_RM_FromVectors(mat, view[0], view[1], view[2], vec3_origin);
@ -628,19 +631,13 @@ void CL_ClampPitch (int pnum)
norm[2] = 1; norm[2] = 1;
} }
{ /*keep the roll relative to the 'ground'*/
vec3_t cross; CrossProduct(norm, view[2], cross);
float roll; dot = DotProduct(view[0], cross);
float dot; roll = timestep * 360 * -(dot);
/*keep the roll relative to the 'ground'*/ Matrix4_Multiply(Matrix4x4_CM_NewRotation(roll, 1, 0, 0), mat, mat2);
CrossProduct(norm, view[2], cross);
dot = DotProduct(view[0], cross);
roll = timestep * 720/M_PI * -(dot);
Con_Printf("%f %f\n", dot, roll);
Matrix4_Multiply(Matrix4x4_CM_NewRotation(roll, 1, 0, 0), mat, mat2);
Matrix3x4_RM_ToVectors(mat2, view[0], view[1], view[2], view[3]);
}
Matrix3x4_RM_ToVectors(mat2, view[0], view[1], view[2], view[3]);
VectorAngles(view[0], view[2], cl.viewangles[pnum]); VectorAngles(view[0], view[2], cl.viewangles[pnum]);
cl.viewangles[pnum][PITCH]=360 - cl.viewangles[pnum][PITCH]; cl.viewangles[pnum][PITCH]=360 - cl.viewangles[pnum][PITCH];
VectorClear(cl.viewanglechange[pnum]); VectorClear(cl.viewanglechange[pnum]);
@ -689,10 +686,15 @@ void CL_ClampPitch (int pnum)
cl.viewangles[pnum][PITCH] = cl.minpitch; cl.viewangles[pnum][PITCH] = cl.minpitch;
} }
if (cl.viewangles[pnum][ROLL] > 50) // if (cl.viewangles[pnum][ROLL] > 50)
cl.viewangles[pnum][ROLL] = 50; // cl.viewangles[pnum][ROLL] = 50;
if (cl.viewangles[pnum][ROLL] < -50) // if (cl.viewangles[pnum][ROLL] < -50)
cl.viewangles[pnum][ROLL] = -50; // cl.viewangles[pnum][ROLL] = -50;
roll = timestep*cl.viewangles[pnum][ROLL]*30;
if ((cl.viewangles[pnum][ROLL]-roll < 0) != (cl.viewangles[pnum][ROLL]<0))
cl.viewangles[pnum][ROLL] = 0;
else
cl.viewangles[pnum][ROLL] -= timestep*cl.viewangles[pnum][ROLL]*3;
} }
/* /*

View File

@ -531,7 +531,7 @@ void CL_SendConnectPacket (int mtu,
Q_strncatz(data, va("0x%x 0x%x\n", PROTOCOL_VERSION_FTE2, fteprotextsupported2), sizeof(data)); Q_strncatz(data, va("0x%x 0x%x\n", PROTOCOL_VERSION_FTE2, fteprotextsupported2), sizeof(data));
#endif #endif
if (mtu >= 0) if (mtu > 0)
{ {
if (adr.type == NA_LOOPBACK) if (adr.type == NA_LOOPBACK)
mtu = 8192; mtu = 8192;

View File

@ -831,8 +831,12 @@ qboolean CL_CheckQ2BspWals(char *file)
break; break;
if (i == j) if (i == j)
if (!CL_CheckOrEnqueDownloadFile(tinf[i].texture, NULL, 0)) {
gotone = true; if (!CL_CheckDLFile(va("textures/%s.wal", tinf[i].texture)))
if (!CL_CheckDLFile(va("textures/%s.tga", tinf[i].texture)))
if (!CL_CheckOrEnqueDownloadFile(tinf[i].texture, NULL, 0))
gotone = true;
}
} }
return gotone; return gotone;
} }

View File

@ -767,21 +767,32 @@ void CL_PlayerFrameUpdated(player_state_t *plstate, entity_state_t *state, int s
{ {
/*update the prediction info*/ /*update the prediction info*/
int pmtype, i; int pmtype, i;
if (state->u.q1.pmovetype == MOVETYPE_NOCLIP) switch(state->u.q1.pmovetype)
{ {
case MOVETYPE_NOCLIP:
if (cls.z_ext & Z_EXT_PM_TYPE_NEW) if (cls.z_ext & Z_EXT_PM_TYPE_NEW)
pmtype = PM_SPECTATOR; pmtype = PM_SPECTATOR;
else else
pmtype = PM_OLD_SPECTATOR; pmtype = PM_OLD_SPECTATOR;
} break;
else if (state->u.q1.pmovetype == MOVETYPE_FLY)
case MOVETYPE_FLY:
pmtype = PM_FLY; pmtype = PM_FLY;
else if (state->u.q1.pmovetype == MOVETYPE_NONE) break;
case MOVETYPE_NONE:
pmtype = PM_NONE; pmtype = PM_NONE;
else if (state->u.q1.pmovetype == MOVETYPE_BOUNCE || state->u.q1.pmovetype == MOVETYPE_TOSS) break;
case MOVETYPE_BOUNCE:
case MOVETYPE_TOSS:
pmtype = PM_DEAD; pmtype = PM_DEAD;
else break;
case MOVETYPE_WALLWALK:
pmtype = PM_WALLWALK;
break;
default:
pmtype = PM_NORMAL; pmtype = PM_NORMAL;
break;
}
plstate->pm_type = pmtype; plstate->pm_type = pmtype;
VectorCopy(state->origin, plstate->origin); VectorCopy(state->origin, plstate->origin);
@ -1015,6 +1026,7 @@ fixedorg:
org = lrp; org = lrp;
vel = lrpv; vel = lrpv;
cl.pmovetype[pnum] = PM_NONE;
goto fixedorg; goto fixedorg;
} }
else else
@ -1054,6 +1066,7 @@ fixedorg:
, &to->playerstate[cl.playernum[pnum]], &to->cmd[pnum]); , &to->playerstate[cl.playernum[pnum]], &to->cmd[pnum]);
} }
cl.onground[pnum] = pmove.onground; cl.onground[pnum] = pmove.onground;
cl.pmovetype[pnum] = to->playerstate[cl.playernum[pnum]].pm_type;
stepheight = to->playerstate[cl.playernum[pnum]].origin[2] - from->playerstate[cl.playernum[pnum]].origin[2]; stepheight = to->playerstate[cl.playernum[pnum]].origin[2] - from->playerstate[cl.playernum[pnum]].origin[2];
if (cl.nolocalplayer[pnum]) if (cl.nolocalplayer[pnum])

View File

@ -658,6 +658,7 @@ typedef struct
qboolean oldfixangle[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet. qboolean oldfixangle[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet.
vec3_t fixangles[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet. vec3_t fixangles[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet.
vec3_t oldfixangles[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet. vec3_t oldfixangles[MAX_SPLITS]; //received a fixangle - so disable prediction till the next packet.
int pmovetype[MAX_SPLITS];
int teamplay; int teamplay;
int deathmatch; int deathmatch;

View File

@ -1090,9 +1090,6 @@ void PM_PlayerMove (float gamespeed)
frametime = pmove.cmd.msec * 0.001*gamespeed; frametime = pmove.cmd.msec * 0.001*gamespeed;
pmove.numtouch = 0; pmove.numtouch = 0;
//TEMP
pmove.pm_type = PM_WALLWALK;
if (pmove.pm_type == PM_NONE || pmove.pm_type == PM_FREEZE) { if (pmove.pm_type == PM_NONE || pmove.pm_type == PM_FREEZE) {
PM_CategorizePosition (); PM_CategorizePosition ();
return; return;

View File

@ -358,6 +358,7 @@ pbool ED_CanFree (edict_t *ed);
#define MOVETYPE_FOLLOW 12 // track movement of aiment #define MOVETYPE_FOLLOW 12 // track movement of aiment
#define MOVETYPE_H2PUSHPULL 13 // pushable/pullable object #define MOVETYPE_H2PUSHPULL 13 // pushable/pullable object
#define MOVETYPE_H2SWIM 14 // should keep the object in water #define MOVETYPE_H2SWIM 14 // should keep the object in water
#define MOVETYPE_WALLWALK 31 // walks up walls and along ceilings
#define MOVETYPE_PHYSICS 32 #define MOVETYPE_PHYSICS 32
// edict->solid values // edict->solid values

View File

@ -424,7 +424,7 @@ enum clcq2_ops_e
#define PMC_FLY 4 // fly, bump into walls #define PMC_FLY 4 // fly, bump into walls
#define PMC_NONE 5 // can't move (client had better lerp the origin...) #define PMC_NONE 5 // can't move (client had better lerp the origin...)
#define PMC_FREEZE 6 // TODO: lerp movement and viewangles #define PMC_FREEZE 6 // TODO: lerp movement and viewangles
#define PMC_EXTRA3 7 // future extension #define PMC_WALLWALK 7 // future extension
//any more will require a different protocol message. //any more will require a different protocol message.

View File

@ -1761,9 +1761,13 @@ void SV_WritePlayerToClient(sizebuf_t *msg, clstate_t *ent)
case PM_NONE: case PM_NONE:
pm_code = PMC_NONE; pm_code = PMC_NONE;
break; break;
case PM_WALLWALK:
pm_code = PMC_WALLWALK;
break;
default: default:
Sys_Error("SV_WritePlayersToClient: unexpected pm_type"); // Sys_Error("SV_WritePlayersToClient: unexpected pm_type");
pm_code=0; pm_code=PMC_NORMAL;
break;
} }
} }
else else

View File

@ -1874,7 +1874,7 @@ client_t *SVC_DirectConnect(void)
case PROTOCOL_VERSION_FRAGMENT: case PROTOCOL_VERSION_FRAGMENT:
mtu = Q_atoi(Cmd_Argv(1)) & ~7; mtu = Q_atoi(Cmd_Argv(1)) & ~7;
if (mtu < 64) if (mtu < 64)
mtu = 64; mtu = 0;
Con_DPrintf("Client supports fragmentation. mtu %i.\n", mtu); Con_DPrintf("Client supports fragmentation. mtu %i.\n", mtu);
break; break;
case PROTOCOL_INFO_GUID: case PROTOCOL_INFO_GUID:
@ -2323,7 +2323,7 @@ client_t *SVC_DirectConnect(void)
newcl->netchan.compress = true; newcl->netchan.compress = true;
else else
newcl->netchan.compress = false; newcl->netchan.compress = false;
if (mtu >= 0) if (mtu >= 64)
newcl->netchan.fragmentsize = mtu; newcl->netchan.fragmentsize = mtu;
newcl->protocol = protocol; newcl->protocol = protocol;

View File

@ -1743,6 +1743,7 @@ void SV_Begin_Core(client_t *split)
split->edict->v->maxs[0] = 16; split->edict->v->maxs[0] = 16;
split->edict->v->maxs[1] = 16; split->edict->v->maxs[1] = 16;
split->edict->v->maxs[2] = 32; split->edict->v->maxs[2] = 32;
split->edict->v->movetype = MOVETYPE_NOCLIP;
} }
} }
@ -5453,23 +5454,30 @@ int SV_PMTypeForClient (client_t *cl)
return PM_NORMAL; return PM_NORMAL;
} }
if (cl->edict->v->movetype == MOVETYPE_NOCLIP) switch((int)cl->edict->v->movetype)
{ {
case MOVETYPE_NOCLIP:
/*older/vanilla clients have a b0rked spectator mode that we don't want to break*/
if (cl->zquake_extensions & Z_EXT_PM_TYPE_NEW) if (cl->zquake_extensions & Z_EXT_PM_TYPE_NEW)
return PM_SPECTATOR; return PM_SPECTATOR;
return PM_OLD_SPECTATOR; return PM_OLD_SPECTATOR;
}
if (cl->edict->v->movetype == MOVETYPE_FLY) case MOVETYPE_WALLWALK:
return PM_WALLWALK;
case MOVETYPE_FLY:
return PM_FLY; return PM_FLY;
if (cl->edict->v->movetype == MOVETYPE_NONE) case MOVETYPE_NONE:
return PM_NONE; return PM_NONE;
if (cl->edict->v->health <= 0) case MOVETYPE_WALK:
return PM_DEAD; default:
if (cl->edict->v->health <= 0)
return PM_DEAD;
return PM_NORMAL; return PM_NORMAL;
}
} }
@ -5839,6 +5847,28 @@ if (sv_player->v->health > 0 && before && !after )
VectorCopy (pmove.origin, sv_player->v->origin); VectorCopy (pmove.origin, sv_player->v->origin);
VectorCopy (pmove.angles, sv_player->v->v_angle); VectorCopy (pmove.angles, sv_player->v->v_angle);
if (pmove.pm_type == PM_WALLWALK)
{
if (!sv_player->v->fixangle)
{
//FIXME: bound to pmove.gravitydir
vec3_t view[3];
vec3_t surf[3];
vec3_t fwd, up;
AngleVectors(sv_player->v->v_angle, view[0], view[1], view[2]);
/*calculate the surface axis with up from the pmove code and right/forwards relative to the player's directions*/
VectorNegate(pmove.gravitydir, surf[2]);
CrossProduct(view[0], surf[2], surf[1]);
VectorNormalize(surf[1]);
CrossProduct(surf[2], surf[1], surf[0]);
/*interpolate the forward direction to be 1/3rd the player, and 2/3rds the surface forward*/
VectorInterpolate(surf[0], 0.333, view[0], fwd);
CrossProduct(surf[1], fwd, up);
/*we have our player's new axis*/
VectorAngles(fwd, up, sv_player->v->angles);
}
}
player_mins[0] = -16; player_mins[0] = -16;
player_mins[1] = -16; player_mins[1] = -16;
player_mins[2] = -24; player_mins[2] = -24;
@ -6223,6 +6253,8 @@ haveannothergo:
if (c == -1) if (c == -1)
break; break;
// Con_Printf("(%s) %i: %i\n", cl->name, msg_readcount, c);
switch (c) switch (c)
{ {
default: default:

View File

@ -1016,11 +1016,12 @@ static trace_t World_ClipMoveToEntity (world_t *w, wedict_t *ent, vec3_t eorg, v
{ {
trace_t trace; trace_t trace;
model_t *model; model_t *model;
int mdlidx = ent->v->modelindex;
// get the clipping hull // get the clipping hull
if (ent->v->solid == SOLID_BSP) if (ent->v->solid == SOLID_BSP && mdlidx)
{ {
model = w->Get_CModel(w, ent->v->modelindex); model = w->Get_CModel(w, mdlidx);
if (!model || (model->type != mod_brush && model->type != mod_heightmap)) if (!model || (model->type != mod_brush && model->type != mod_heightmap))
Host_Error("SOLID_BSP with non bsp model (classname: %s)", PR_GetString(w->progs, ent->v->classname)); Host_Error("SOLID_BSP with non bsp model (classname: %s)", PR_GetString(w->progs, ent->v->classname));
} }
@ -1046,12 +1047,10 @@ static trace_t World_ClipMoveToEntity (world_t *w, wedict_t *ent, vec3_t eorg, v
} }
// if using hitmodel, we know it hit the bounding box, so try a proper trace now. // if using hitmodel, we know it hit the bounding box, so try a proper trace now.
if (hitmodel && trace.fraction != 1 && ent->v->solid != SOLID_BSP && ent->v->modelindex != 0) if (hitmodel && trace.fraction != 1 && ent->v->solid != SOLID_BSP && mdlidx != 0)
{ {
//okay, we hit the bbox //okay, we hit the bbox
model = w->Get_CModel(w, mdlidx);
model_t *model;
model = w->Get_CModel(w, ent->v->modelindex);
if (model && model->funcs.NativeTrace) if (model && model->funcs.NativeTrace)
{ {