Skip to content

Commit

Permalink
Merge pull request #35 from TomyLobo/fix-unstick
Browse files Browse the repository at this point in the history
Fix da_auto_unstick
  • Loading branch information
TomyLobo committed Mar 30, 2016
2 parents 1150338 + a9c49b2 commit ab37427
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions mp/src/game/server/da/da_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ CDAPlayer::CDAPlayer()
m_flCurrentTime = gpGlobals->curtime;

m_iszCharacter = NULL_STRING;

m_flStuckTime = -1;
}


Expand Down
1 change: 1 addition & 0 deletions mp/src/game/server/da/da_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ class CDAPlayer : public CBaseMultiplayerPlayer

int m_iKills;
int m_iDeaths;
float m_flStuckTime;

CNetworkHandle(CDAPlayer, m_hKiller);
CNetworkHandle(CBaseEntity, m_hInflictor);
Expand Down
16 changes: 8 additions & 8 deletions mp/src/game/shared/da/da_gamemovement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ class CDAGameMovement : public CGameMovement
bool ResolveStanding( void );
void TracePlayerBBoxWithStep( const Vector &vStart, const Vector &vEnd, unsigned int fMask, int collisionGroup, trace_t &trace );
public:
// A reference to the player whose movement is currently being considered.
// If additional per-player data is needed, put it into CDAPlayer and refer to it via m_pDAPlayer.
// Do not put it directly into CDAGameMovement, because there isn't an instance of that per player.
CDAPlayer *m_pDAPlayer;

#ifdef STUCK_DEBUG
float m_flStuckCheck;

void AddBotTag(const char* tag);
#endif

float m_flStuckTime;
};

#define ROLL_TIME 0.65f
Expand All @@ -160,7 +161,6 @@ CDAGameMovement::CDAGameMovement()
#ifdef STUCK_DEBUG
m_flStuckCheck = 0;
#endif
m_flStuckTime = -1;
}

CDAGameMovement::~CDAGameMovement()
Expand Down Expand Up @@ -611,19 +611,19 @@ void CDAGameMovement::PlayerMove (void)
#ifndef CLIENT_DLL
if (da_auto_unstick.GetBool() && m_pDAPlayer->IsAlive() && PlayerIsStuck() && m_pDAPlayer->GetMoveType() != MOVETYPE_NOCLIP)
{
if (m_flStuckTime < 0)
m_flStuckTime = gpGlobals->curtime;
else if (gpGlobals->curtime - m_flStuckTime > 3)
if (m_pDAPlayer->m_flStuckTime < 0)
m_pDAPlayer->m_flStuckTime = gpGlobals->curtime;
else if (gpGlobals->curtime - m_pDAPlayer->m_flStuckTime > 3)
{
// Im hopelessly stuck. Respawn me.
CBaseEntity* spawn = DAGameRules()->GetPlayerSpawnSpot(m_pDAPlayer);
mv->SetAbsOrigin(spawn->GetAbsOrigin());
mv->m_vecVelocity = Vector(0, 0, 0);
m_flStuckTime = -1;
m_pDAPlayer->m_flStuckTime = -1;
}
}
else
m_flStuckTime = -1;
m_pDAPlayer->m_flStuckTime = -1;
#endif

#ifdef STUCK_DEBUG
Expand Down

0 comments on commit ab37427

Please sign in to comment.