avoid getting stuck when un-crouching

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2778 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-09-27 16:20:32 +00:00
parent 0262c14aeb
commit 8284aaf7b3
2 changed files with 5 additions and 2 deletions
+3 -2
View File
@@ -104,6 +104,7 @@ struct physent
char move, strafe;
uchar state, type;
static const int crouchtime;
float lastspacehi;
physent() : o(0, 0, 0), deltapos(0, 0, 0), newpos(0, 0, 0), yaw(270), pitch(0), roll(0), pitchvel(0),
crouching(false), trycrouch(false), cancollide(true), stuck(false), lastcrouch(0), lastsplash(0), state(CS_ALIVE)
@@ -120,13 +121,13 @@ struct physent
void reset()
{
vel.x = vel.y = vel.z = 0;
vel.x = vel.y = vel.z = lastspacehi = 0.0f;
move = strafe = 0;
timeinair = lastcrouch = lastsplash = 0;
onfloor = onladder = inwater = jumpnext = crouching = trycrouch = stuck = false;
}
virtual float dyneyeheight()
virtual float dyneyeheight() const
{
extern int lastmillis;
const float croucheyeheight = eyeheight*3.0f/4.0f;
+2
View File
@@ -241,6 +241,7 @@ bool collide(physent *d, bool spawn, float drop, float rise)
}
d->onfloor = d->o.z-eyeheight-lo < (lastmillis-d->lastcrouch<=physent::crouchtime ? 0.1f : 0.01f);
d->lastspacehi = spacehi;
}
return true;
}
@@ -605,6 +606,7 @@ void jumpn(bool on)
void updatecrouch(playerent *p, bool on)
{
if(p->crouching == on) return;
if(p==player1 && p->lastspacehi<1.0f && !on) return;
p->crouching = on;
const int progress = lastmillis-p->lastcrouch;
if(progress > physent::crouchtime) p->lastcrouch = lastmillis; // new crouch