From c078470162695c351cbf4c26baea145926abf609 Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 6 Nov 2009 14:24:21 +0000 Subject: [PATCH] fix two bugs introduced in r5828 (2005-11-25) that made monsters and corpses slide off of groundentity thanks to negke for reporting this bug and assisting in identifying it git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9439 d7cf8633-e32d-0410-b094-e92efae38249 --- sv_phys.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sv_phys.c b/sv_phys.c index 5c239777..bd8b50ce 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -2434,10 +2434,12 @@ void SV_Physics_Toss (prvm_edict_t *ent) vec3_t move; vec_t movetime; int bump; + prvm_edict_t *groundentity; // if onground, return without moving if ((int)ent->fields.server->flags & FL_ONGROUND) { + groundentity = PRVM_PROG_TO_EDICT(ent->fields.server->groundentity); if (ent->fields.server->velocity[2] >= (1.0 / 32.0) && sv_gameplayfix_upwardvelocityclearsongroundflag.integer) { // don't stick to ground if onground and moving upward @@ -2448,7 +2450,7 @@ void SV_Physics_Toss (prvm_edict_t *ent) // we can trust FL_ONGROUND if groundentity is world because it never moves return; } - else if (ent->priv.server->suspendedinairflag && PRVM_PROG_TO_EDICT(ent->fields.server->groundentity)->priv.server->free) + else if (ent->priv.server->suspendedinairflag && groundentity->priv.server->free) { // if ent was supported by a brush model on previous frame, // and groundentity is now freed, set groundentity to 0 (world) @@ -2457,6 +2459,11 @@ void SV_Physics_Toss (prvm_edict_t *ent) if (sv_gameplayfix_noairborncorpse_allowsuspendeditems.integer) return; } + else if (BoxesOverlap(ent->priv.server->cullmins, ent->priv.server->cullmaxs, groundentity->priv.server->cullmins, groundentity->priv.server->cullmaxs)) + { + // don't slide if still touching the groundentity + return; + } } ent->priv.server->suspendedinairflag = false; @@ -2608,7 +2615,7 @@ void SV_Physics_Step (prvm_edict_t *ent) { // freefall if onground and moving upward // freefall if not standing on a world surface (it may be a lift or trap door) - if ((ent->fields.server->velocity[2] >= (1.0 / 32.0) && sv_gameplayfix_upwardvelocityclearsongroundflag.integer) || ent->fields.server->groundentity) + if (ent->fields.server->velocity[2] >= (1.0 / 32.0) && sv_gameplayfix_upwardvelocityclearsongroundflag.integer) { ent->fields.server->flags -= FL_ONGROUND; SV_CheckVelocity(ent); -- 2.39.2