Removed redundant if block in g_phys.c->SV_Physics_Step().

Fixed switch statement fallthrough in func_pushable water current code.
This commit is contained in:
Knightmare66 2019-07-30 17:50:32 -04:00
parent fe7685022f
commit 801a8292b3

View file

@ -1051,14 +1051,15 @@ qboolean SV_Push (edict_t *pusher, vec3_t move, vec3_t amove)
VectorAdd (check->s.origin, move, check->s.origin); VectorAdd (check->s.origin, move, check->s.origin);
// Lazarus: if turn_rider is set, do it. We don't do this by default // Lazarus: if turn_rider is set, do it. We don't do this by default
// 'cause it can be a fairly drastic change in gameplay // 'cause it can be a fairly drastic change in gameplay
if (turn && (check->groundentity == pusher)) { if (turn && (check->groundentity == pusher))
{
if(!check->client) if(!check->client)
{ {
check->s.angles[YAW] += amove[YAW]; check->s.angles[YAW] += amove[YAW];
} }
else else
{ {
if(amove[YAW] != 0.) if (amove[YAW] != 0.0f)
{ {
check->client->ps.pmove.delta_angles[YAW] += ANGLE2SHORT(amove[YAW]); check->client->ps.pmove.delta_angles[YAW] += ANGLE2SHORT(amove[YAW]);
check->client->ps.viewangles[YAW] += amove[YAW]; check->client->ps.viewangles[YAW] += amove[YAW];
@ -1073,7 +1074,7 @@ qboolean SV_Push (edict_t *pusher, vec3_t move, vec3_t amove)
// player is riding a MOVETYPE_PUSH // player is riding a MOVETYPE_PUSH
check->client->ps.pmove.pm_flags |= PMF_NO_PREDICTION; check->client->ps.pmove.pm_flags |= PMF_NO_PREDICTION;
} }
if(amove[PITCH] != 0.) if(amove[PITCH] != 0.0f)
{ {
float delta_yaw; float delta_yaw;
float pitch = amove[PITCH]; float pitch = amove[PITCH];
@ -1790,7 +1791,8 @@ void SV_Physics_Step (edict_t *ent)
// Lazarus: Floating stuff // Lazarus: Floating stuff
if ((ent->movetype == MOVETYPE_PUSHABLE) && (ent->flags & FL_SWIM) && (ent->waterlevel)) { if ((ent->movetype == MOVETYPE_PUSHABLE) && (ent->flags & FL_SWIM) && (ent->waterlevel))
{
float waterlevel; float waterlevel;
float rider_mass, total_mass; float rider_mass, total_mass;
trace_t tr; trace_t tr;
@ -1810,7 +1812,8 @@ void SV_Physics_Step (edict_t *ent)
rider_mass = RiderMass(ent); rider_mass = RiderMass(ent);
total_mass = rider_mass + ent->mass; total_mass = rider_mass + ent->mass;
Area = ent->size[0] * ent->size[1]; Area = ent->size[0] * ent->size[1];
if(waterlevel < ent->absmax[2]) { if (waterlevel < ent->absmax[2])
{
// A portion of crate is above water // A portion of crate is above water
int time; int time;
float t0, t1, z0, z1; float t0, t1, z0, z1;
@ -1841,10 +1844,13 @@ void SV_Physics_Step (edict_t *ent)
z1 = sin(2*M_PI*t1/time); z1 = sin(2*M_PI*t1/time);
ent->velocity[2] += ent->bob * (z1-z0) * 10; ent->velocity[2] += ent->bob * (z1-z0) * 10;
ent->bobframe = (ent->bobframe+1)%time; ent->bobframe = (ent->bobframe+1)%time;
} else { }
else
{
// Crate is fully submerged // Crate is fully submerged
Force = -total_mass + ent->volume * WATER_DENSITY; Force = -total_mass + ent->volume * WATER_DENSITY;
if(sv_gravity->value) { if (sv_gravity->value)
{
Drag = 0.00190735 * 1.05 * Area * (ent->velocity[2]*ent->velocity[2])/sv_gravity->value; Drag = 0.00190735 * 1.05 * Area * (ent->velocity[2]*ent->velocity[2])/sv_gravity->value;
if(Drag > fabs(Force)) { if(Drag > fabs(Force)) {
// Drag actually CAN be > total weight, but if we do this we tend to // Drag actually CAN be > total weight, but if we do this we tend to
@ -1860,7 +1866,8 @@ void SV_Physics_Step (edict_t *ent)
ent->velocity[2] += Accel*FRAMETIME; ent->velocity[2] += Accel*FRAMETIME;
} }
if(ent->watertype & MASK_CURRENT) { if (ent->watertype & MASK_CURRENT)
{
// Move with current, relative to mass. Mass=400 or less // Move with current, relative to mass. Mass=400 or less
// will move at 50 units/sec. // will move at 50 units/sec.
float v; float v;
@ -1877,8 +1884,8 @@ void SV_Physics_Step (edict_t *ent)
case CONTENTS_CURRENT_90: ent->velocity[1] = v; break; case CONTENTS_CURRENT_90: ent->velocity[1] = v; break;
case CONTENTS_CURRENT_180: ent->velocity[0] = -v; break; case CONTENTS_CURRENT_180: ent->velocity[0] = -v; break;
case CONTENTS_CURRENT_270: ent->velocity[1] = -v; break; case CONTENTS_CURRENT_270: ent->velocity[1] = -v; break;
case CONTENTS_CURRENT_UP : ent->velocity[2] = max(v, ent->velocity[2]); case CONTENTS_CURRENT_UP : ent->velocity[2] = max(v, ent->velocity[2]); break;
case CONTENTS_CURRENT_DOWN: ent->velocity[2] = min(-v, ent->velocity[2]); case CONTENTS_CURRENT_DOWN: ent->velocity[2] = min(-v, ent->velocity[2]); break;
} }
} }
} }
@ -1911,16 +1918,17 @@ void SV_Physics_Step (edict_t *ent)
} }
} }
if (ent->velocity[2] || ent->velocity[1] || ent->velocity[0]) { if (ent->velocity[2] || ent->velocity[1] || ent->velocity[0])
{
int block; int block;
// apply friction // apply friction
// let dead monsters who aren't completely onground slide // let dead monsters who aren't completely onground slide
if ((wasonground) || (ent->flags & (FL_SWIM|FL_FLY))) if ((wasonground) || (ent->flags & (FL_SWIM|FL_FLY)))
if (!onconveyor) if (!onconveyor)
{ {
if (!(ent->health <= 0.0 && !M_CheckBottom(ent))) { if (!(ent->health <= 0.0 && !M_CheckBottom(ent)))
{
vel = ent->velocity; vel = ent->velocity;
speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1]); speed = sqrt(vel[0]*vel[0] +vel[1]*vel[1]);
if (speed) { if (speed) {
@ -1990,7 +1998,8 @@ void SV_Physics_Step (edict_t *ent)
if(ent->bounce_me == 2) if(ent->bounce_me == 2)
VectorMA(old_origin,FRAMETIME,ent->velocity,ent->s.origin); VectorMA(old_origin,FRAMETIME,ent->velocity,ent->s.origin);
VectorSubtract(ent->s.origin,old_origin,move); VectorSubtract(ent->s.origin,old_origin,move);
for(i=1, e=g_edicts+i; i<globals.num_edicts; i++, e++) { for (i=1, e=g_edicts+i; i<globals.num_edicts; i++, e++)
{
if (e==ent) continue; if (e==ent) continue;
if (e->groundentity == ent) { if (e->groundentity == ent) {
VectorAdd(e->s.origin,move,end); VectorAdd(e->s.origin,move,end);
@ -2011,15 +2020,6 @@ void SV_Physics_Step (edict_t *ent)
if (!ent->inuse) return; if (!ent->inuse) return;
} }
else if(ent->movetype == MOVETYPE_PUSHABLE)
{
// We run touch function for non-moving func_pushables every frame
// to see if they are touching, for example, a trigger_mass
G_TouchTriggers(ent);
if(!ent->inuse) return;
}
// Lazarus: Add falling damage for entities that can be damaged // Lazarus: Add falling damage for entities that can be damaged
if (ent->takedamage == DAMAGE_YES) if (ent->takedamage == DAMAGE_YES)
{ {